{"action":"created","comment":{"url":"https://api.github.com/repos/awslabs/aws-cdk/pulls/comments/208492993","pull_request_review_id":144310841,"id":208492993,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwODQ5Mjk5Mw==","diff_hunk":"@@ -133,3 +179,128 @@ export function resolve(obj: any, prefix?: string[]): any {\n \n     return result;\n }\n+\n+import { FnConcat } from \"../cloudformation/fn\";\n+\n+/**\n+ * Central place where we keep a mapping from Tokens to their String representation\n+ *\n+ * The string representation is used to embed token into strings,\n+ * and stored to be able to\n+ *\n+ * All instances of TokenStringMap share the same storage, so that this process\n+ * works even when different copies of the library are loaded.\n+ */\n+class TokenStringMap {\n+    private readonly tokenMap: {[key: string]: Token};\n+\n+    constructor() {\n+        const glob = global as any;\n+        this.tokenMap = glob.__cdkTokenMap = glob.__cdkTokenMap || {};\n+    }\n+\n+    /**\n+     * Return a unique string for this Token\n+     *\n+     * Every call for the same Token will produce a new unique string, no\n+     * attempt is made to deduplicate. Token objects should cache the\n+     * value themselves, if required.\n+     *\n+     * If the token is an IRepresentableToken, it chooses its own representation\n+     * string. This may be used to produce aesthetically pleasing and recognizable\n+     * token representations for humans.\n+     */\n+    public register(token: Token | HintedToken): string {\n+        const counter = Object.keys(this.tokenMap).length;\n+        const representation = isHintedToken(token) ? token.representationHint : `TOKEN`;\n+\n+        const key = `${representation}.${counter}`;\n+        if (new RegExp(`[^${VALID_KEY_CHARS}]`).exec(key)) {\n+            throw new Error(`Invalid characters in token representation: ${key}`);\n+        }\n+\n+        this.tokenMap[key] = token;","path":"packages/@aws-cdk/cdk/lib/core/tokens.ts","position":111,"original_position":111,"commit_id":"3796389e5d571dbd89fc0cda4dfd4f4c8cdc2eee","original_commit_id":"3796389e5d571dbd89fc0cda4dfd4f4c8cdc2eee","user":{"login":"rix0rrr","id":524162,"node_id":"MDQ6VXNlcjUyNDE2Mg==","avatar_url":"https://avatars2.githubusercontent.com/u/524162?v=4","gravatar_id":"","url":"https://api.github.com/users/rix0rrr","html_url":"https://github.com/rix0rrr","followers_url":"https://api.github.com/users/rix0rrr/followers","following_url":"https://api.github.com/users/rix0rrr/following{/other_user}","gists_url":"https://api.github.com/users/rix0rrr/gists{/gist_id}","starred_url":"https://api.github.com/users/rix0rrr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rix0rrr/subscriptions","organizations_url":"https://api.github.com/users/rix0rrr/orgs","repos_url":"https://api.github.com/users/rix0rrr/repos","events_url":"https://api.github.com/users/rix0rrr/events{/privacy}","received_events_url":"https://api.github.com/users/rix0rrr/received_events","type":"User","site_admin":false},"body":"Can't really happen since every one gets a unique number that's guaranteed to not occur in the map yet.","created_at":"2018-08-08T08:12:45Z","updated_at":"2018-08-08T08:12:45Z","html_url":"https://github.com/awslabs/aws-cdk/pull/518#discussion_r208492993","pull_request_url":"https://api.github.com/repos/awslabs/aws-cdk/pulls/518","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/awslabs/aws-cdk/pulls/comments/208492993"},"html":{"href":"https://github.com/awslabs/aws-cdk/pull/518#discussion_r208492993"},"pull_request":{"href":"https://api.github.com/repos/awslabs/aws-cdk/pulls/518"}},"in_reply_to_id":208230227},"pull_request":{"url":"https://api.github.com/repos/awslabs/aws-cdk/pulls/518","id":206689976,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA2Njg5OTc2","html_url":"https://github.com/awslabs/aws-cdk/pull/518","diff_url":"https://github.com/awslabs/aws-cdk/pull/518.diff","patch_url":"https://github.com/awslabs/aws-cdk/pull/518.patch","issue_url":"https://api.github.com/repos/awslabs/aws-cdk/issues/518","number":518,"state":"open","locked":false,"title":"Framework: Tokens can be converted to strings","user":{"login":"rix0rrr","id":524162,"node_id":"MDQ6VXNlcjUyNDE2Mg==","avatar_url":"https://avatars2.githubusercontent.com/u/524162?v=4","gravatar_id":"","url":"https://api.github.com/users/rix0rrr","html_url":"https://github.com/rix0rrr","followers_url":"https://api.github.com/users/rix0rrr/followers","following_url":"https://api.github.com/users/rix0rrr/following{/other_user}","gists_url":"https://api.github.com/users/rix0rrr/gists{/gist_id}","starred_url":"https://api.github.com/users/rix0rrr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rix0rrr/subscriptions","organizations_url":"https://api.github.com/users/rix0rrr/orgs","repos_url":"https://api.github.com/users/rix0rrr/repos","events_url":"https://api.github.com/users/rix0rrr/events{/privacy}","received_events_url":"https://api.github.com/users/rix0rrr/received_events","type":"User","site_admin":false},"body":"Tokens (such as resource attributes) can now be implicitly converted\r\ninto strings. Parameters and attributes can now be combined into larger\r\nstrings using the native string facilities of the host language.\r\n\r\nThe process will be reversed by the resolve() function during synthesis,\r\nwhich will split the string up again into string literals and\r\nCloudFormation intrinsics.\r\n\r\nThe same transformation is applied during JSON.stringify(), so that\r\nTokens in a complex JSON structure are preserved.\r\n\r\nFixes #24 and #168.\r\n\r\nBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.\r\n","created_at":"2018-08-07T13:01:15Z","updated_at":"2018-08-08T08:12:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7d5b8f906bc4b84fe0dea32f0df3ae6de091ff8e","assignee":null,"assignees":[],"requested_reviewers":[{"login":"RomainMuller","id":411689,"node_id":"MDQ6VXNlcjQxMTY4OQ==","avatar_url":"https://avatars2.githubusercontent.com/u/411689?v=4","gravatar_id":"","url":"https://api.github.com/users/RomainMuller","html_url":"https://github.com/RomainMuller","followers_url":"https://api.github.com/users/RomainMuller/followers","following_url":"https://api.github.com/users/RomainMuller/following{/other_user}","gists_url":"https://api.github.com/users/RomainMuller/gists{/gist_id}","starred_url":"https://api.github.com/users/RomainMuller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RomainMuller/subscriptions","organizations_url":"https://api.github.com/users/RomainMuller/orgs","repos_url":"https://api.github.com/users/RomainMuller/repos","events_url":"https://api.github.com/users/RomainMuller/events{/privacy}","received_events_url":"https://api.github.com/users/RomainMuller/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/awslabs/aws-cdk/pulls/518/commits","review_comments_url":"https://api.github.com/repos/awslabs/aws-cdk/pulls/518/comments","review_comment_url":"https://api.github.com/repos/awslabs/aws-cdk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/awslabs/aws-cdk/issues/518/comments","statuses_url":"https://api.github.com/repos/awslabs/aws-cdk/statuses/3796389e5d571dbd89fc0cda4dfd4f4c8cdc2eee","head":{"label":"awslabs:huijbers/token-stringification","ref":"huijbers/token-stringification","sha":"3796389e5d571dbd89fc0cda4dfd4f4c8cdc2eee","user":{"login":"awslabs","id":3299148,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyOTkxNDg=","avatar_url":"https://avatars0.githubusercontent.com/u/3299148?v=4","gravatar_id":"","url":"https://api.github.com/users/awslabs","html_url":"https://github.com/awslabs","followers_url":"https://api.github.com/users/awslabs/followers","following_url":"https://api.github.com/users/awslabs/following{/other_user}","gists_url":"https://api.github.com/users/awslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/awslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awslabs/subscriptions","organizations_url":"https://api.github.com/users/awslabs/orgs","repos_url":"https://api.github.com/users/awslabs/repos","events_url":"https://api.github.com/users/awslabs/events{/privacy}","received_events_url":"https://api.github.com/users/awslabs/received_events","type":"Organization","site_admin":false},"repo":{"id":105808767,"node_id":"MDEwOlJlcG9zaXRvcnkxMDU4MDg3Njc=","name":"aws-cdk","full_name":"awslabs/aws-cdk","owner":{"login":"awslabs","id":3299148,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyOTkxNDg=","avatar_url":"https://avatars0.githubusercontent.com/u/3299148?v=4","gravatar_id":"","url":"https://api.github.com/users/awslabs","html_url":"https://github.com/awslabs","followers_url":"https://api.github.com/users/awslabs/followers","following_url":"https://api.github.com/users/awslabs/following{/other_user}","gists_url":"https://api.github.com/users/awslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/awslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awslabs/subscriptions","organizations_url":"https://api.github.com/users/awslabs/orgs","repos_url":"https://api.github.com/users/awslabs/repos","events_url":"https://api.github.com/users/awslabs/events{/privacy}","received_events_url":"https://api.github.com/users/awslabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/awslabs/aws-cdk","description":"The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code","fork":false,"url":"https://api.github.com/repos/awslabs/aws-cdk","forks_url":"https://api.github.com/repos/awslabs/aws-cdk/forks","keys_url":"https://api.github.com/repos/awslabs/aws-cdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/awslabs/aws-cdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/awslabs/aws-cdk/teams","hooks_url":"https://api.github.com/repos/awslabs/aws-cdk/hooks","issue_events_url":"https://api.github.com/repos/awslabs/aws-cdk/issues/events{/number}","events_url":"https://api.github.com/repos/awslabs/aws-cdk/events","assignees_url":"https://api.github.com/repos/awslabs/aws-cdk/assignees{/user}","branches_url":"https://api.github.com/repos/awslabs/aws-cdk/branches{/branch}","tags_url":"https://api.github.com/repos/awslabs/aws-cdk/tags","blobs_url":"https://api.github.com/repos/awslabs/aws-cdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/awslabs/aws-cdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/awslabs/aws-cdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/awslabs/aws-cdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/awslabs/aws-cdk/statuses/{sha}","languages_url":"https://api.github.com/repos/awslabs/aws-cdk/languages","stargazers_url":"https://api.github.com/repos/awslabs/aws-cdk/stargazers","contributors_url":"https://api.github.com/repos/awslabs/aws-cdk/contributors","subscribers_url":"https://api.github.com/repos/awslabs/aws-cdk/subscribers","subscription_url":"https://api.github.com/repos/awslabs/aws-cdk/subscription","commits_url":"https://api.github.com/repos/awslabs/aws-cdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/awslabs/aws-cdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/awslabs/aws-cdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/awslabs/aws-cdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/awslabs/aws-cdk/contents/{+path}","compare_url":"https://api.github.com/repos/awslabs/aws-cdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/awslabs/aws-cdk/merges","archive_url":"https://api.github.com/repos/awslabs/aws-cdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/awslabs/aws-cdk/downloads","issues_url":"https://api.github.com/repos/awslabs/aws-cdk/issues{/number}","pulls_url":"https://api.github.com/repos/awslabs/aws-cdk/pulls{/number}","milestones_url":"https://api.github.com/repos/awslabs/aws-cdk/milestones{/number}","notifications_url":"https://api.github.com/repos/awslabs/aws-cdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/awslabs/aws-cdk/labels{/name}","releases_url":"https://api.github.com/repos/awslabs/aws-cdk/releases{/id}","deployments_url":"https://api.github.com/repos/awslabs/aws-cdk/deployments","created_at":"2017-10-04T19:22:36Z","updated_at":"2018-08-08T06:12:01Z","pushed_at":"2018-08-07T21:58:17Z","git_url":"git://github.com/awslabs/aws-cdk.git","ssh_url":"git@github.com:awslabs/aws-cdk.git","clone_url":"https://github.com/awslabs/aws-cdk.git","svn_url":"https://github.com/awslabs/aws-cdk","homepage":"https://awslabs.github.io/aws-cdk","size":71165,"stargazers_count":479,"watchers_count":479,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":20,"mirror_url":null,"archived":false,"open_issues_count":196,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":20,"open_issues":196,"watchers":479,"default_branch":"master"}},"base":{"label":"awslabs:master","ref":"master","sha":"42b108d1b277688ab92af85274e6c85957d9b09c","user":{"login":"awslabs","id":3299148,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyOTkxNDg=","avatar_url":"https://avatars0.githubusercontent.com/u/3299148?v=4","gravatar_id":"","url":"https://api.github.com/users/awslabs","html_url":"https://github.com/awslabs","followers_url":"https://api.github.com/users/awslabs/followers","following_url":"https://api.github.com/users/awslabs/following{/other_user}","gists_url":"https://api.github.com/users/awslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/awslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awslabs/subscriptions","organizations_url":"https://api.github.com/users/awslabs/orgs","repos_url":"https://api.github.com/users/awslabs/repos","events_url":"https://api.github.com/users/awslabs/events{/privacy}","received_events_url":"https://api.github.com/users/awslabs/received_events","type":"Organization","site_admin":false},"repo":{"id":105808767,"node_id":"MDEwOlJlcG9zaXRvcnkxMDU4MDg3Njc=","name":"aws-cdk","full_name":"awslabs/aws-cdk","owner":{"login":"awslabs","id":3299148,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyOTkxNDg=","avatar_url":"https://avatars0.githubusercontent.com/u/3299148?v=4","gravatar_id":"","url":"https://api.github.com/users/awslabs","html_url":"https://github.com/awslabs","followers_url":"https://api.github.com/users/awslabs/followers","following_url":"https://api.github.com/users/awslabs/following{/other_user}","gists_url":"https://api.github.com/users/awslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/awslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awslabs/subscriptions","organizations_url":"https://api.github.com/users/awslabs/orgs","repos_url":"https://api.github.com/users/awslabs/repos","events_url":"https://api.github.com/users/awslabs/events{/privacy}","received_events_url":"https://api.github.com/users/awslabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/awslabs/aws-cdk","description":"The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code","fork":false,"url":"https://api.github.com/repos/awslabs/aws-cdk","forks_url":"https://api.github.com/repos/awslabs/aws-cdk/forks","keys_url":"https://api.github.com/repos/awslabs/aws-cdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/awslabs/aws-cdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/awslabs/aws-cdk/teams","hooks_url":"https://api.github.com/repos/awslabs/aws-cdk/hooks","issue_events_url":"https://api.github.com/repos/awslabs/aws-cdk/issues/events{/number}","events_url":"https://api.github.com/repos/awslabs/aws-cdk/events","assignees_url":"https://api.github.com/repos/awslabs/aws-cdk/assignees{/user}","branches_url":"https://api.github.com/repos/awslabs/aws-cdk/branches{/branch}","tags_url":"https://api.github.com/repos/awslabs/aws-cdk/tags","blobs_url":"https://api.github.com/repos/awslabs/aws-cdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/awslabs/aws-cdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/awslabs/aws-cdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/awslabs/aws-cdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/awslabs/aws-cdk/statuses/{sha}","languages_url":"https://api.github.com/repos/awslabs/aws-cdk/languages","stargazers_url":"https://api.github.com/repos/awslabs/aws-cdk/stargazers","contributors_url":"https://api.github.com/repos/awslabs/aws-cdk/contributors","subscribers_url":"https://api.github.com/repos/awslabs/aws-cdk/subscribers","subscription_url":"https://api.github.com/repos/awslabs/aws-cdk/subscription","commits_url":"https://api.github.com/repos/awslabs/aws-cdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/awslabs/aws-cdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/awslabs/aws-cdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/awslabs/aws-cdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/awslabs/aws-cdk/contents/{+path}","compare_url":"https://api.github.com/repos/awslabs/aws-cdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/awslabs/aws-cdk/merges","archive_url":"https://api.github.com/repos/awslabs/aws-cdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/awslabs/aws-cdk/downloads","issues_url":"https://api.github.com/repos/awslabs/aws-cdk/issues{/number}","pulls_url":"https://api.github.com/repos/awslabs/aws-cdk/pulls{/number}","milestones_url":"https://api.github.com/repos/awslabs/aws-cdk/milestones{/number}","notifications_url":"https://api.github.com/repos/awslabs/aws-cdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/awslabs/aws-cdk/labels{/name}","releases_url":"https://api.github.com/repos/awslabs/aws-cdk/releases{/id}","deployments_url":"https://api.github.com/repos/awslabs/aws-cdk/deployments","created_at":"2017-10-04T19:22:36Z","updated_at":"2018-08-08T06:12:01Z","pushed_at":"2018-08-07T21:58:17Z","git_url":"git://github.com/awslabs/aws-cdk.git","ssh_url":"git@github.com:awslabs/aws-cdk.git","clone_url":"https://github.com/awslabs/aws-cdk.git","svn_url":"https://github.com/awslabs/aws-cdk","homepage":"https://awslabs.github.io/aws-cdk","size":71165,"stargazers_count":479,"watchers_count":479,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":20,"mirror_url":null,"archived":false,"open_issues_count":196,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":20,"open_issues":196,"watchers":479,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/awslabs/aws-cdk/pulls/518"},"html":{"href":"https://github.com/awslabs/aws-cdk/pull/518"},"issue":{"href":"https://api.github.com/repos/awslabs/aws-cdk/issues/518"},"comments":{"href":"https://api.github.com/repos/awslabs/aws-cdk/issues/518/comments"},"review_comments":{"href":"https://api.github.com/repos/awslabs/aws-cdk/pulls/518/comments"},"review_comment":{"href":"https://api.github.com/repos/awslabs/aws-cdk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/awslabs/aws-cdk/pulls/518/commits"},"statuses":{"href":"https://api.github.com/repos/awslabs/aws-cdk/statuses/3796389e5d571dbd89fc0cda4dfd4f4c8cdc2eee"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"rix0rrr"}}