@cargo-ai/cdk 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +55 -8
  2. package/build/src/cli/commands/types.js +11 -35
  3. package/build/src/core.d.ts +1 -1
  4. package/build/src/core.d.ts.map +1 -1
  5. package/build/src/deploy/apply.d.ts +6 -0
  6. package/build/src/deploy/apply.d.ts.map +1 -1
  7. package/build/src/deploy/apply.js +4 -0
  8. package/build/src/deploy/destroy.d.ts.map +1 -1
  9. package/build/src/deploy/destroy.js +33 -0
  10. package/build/src/deploy/executors.live.d.ts.map +1 -1
  11. package/build/src/deploy/executors.live.js +157 -1
  12. package/build/src/deploy/readers.live.d.ts.map +1 -1
  13. package/build/src/deploy/readers.live.js +34 -1
  14. package/build/src/index.d.ts +9 -5
  15. package/build/src/index.d.ts.map +1 -1
  16. package/build/src/index.js +4 -2
  17. package/build/src/refs.d.ts +22 -0
  18. package/build/src/refs.d.ts.map +1 -1
  19. package/build/src/refs.js +11 -2
  20. package/build/src/resources/actions.d.ts +39 -19
  21. package/build/src/resources/actions.d.ts.map +1 -1
  22. package/build/src/resources/actions.js +60 -33
  23. package/build/src/resources/agent.d.ts +10 -23
  24. package/build/src/resources/agent.d.ts.map +1 -1
  25. package/build/src/resources/agent.js +8 -25
  26. package/build/src/resources/app.d.ts +3 -1
  27. package/build/src/resources/app.d.ts.map +1 -1
  28. package/build/src/resources/app.js +2 -1
  29. package/build/src/resources/connector.d.ts +10 -0
  30. package/build/src/resources/connector.d.ts.map +1 -1
  31. package/build/src/resources/connector.js +18 -1
  32. package/build/src/resources/customIntegration.d.ts +12 -0
  33. package/build/src/resources/customIntegration.d.ts.map +1 -0
  34. package/build/src/resources/customIntegration.js +18 -0
  35. package/build/src/resources/mcpServer.d.ts +8 -10
  36. package/build/src/resources/mcpServer.d.ts.map +1 -1
  37. package/build/src/resources/mcpServer.js +4 -7
  38. package/build/src/resources/model.d.ts +36 -1
  39. package/build/src/resources/model.d.ts.map +1 -1
  40. package/build/src/resources/model.js +38 -1
  41. package/build/src/resources/relationship.d.ts +21 -0
  42. package/build/src/resources/relationship.d.ts.map +1 -0
  43. package/build/src/resources/relationship.js +39 -0
  44. package/build/src/resources/worker.d.ts +13 -1
  45. package/build/src/resources/worker.d.ts.map +1 -1
  46. package/build/src/resources/worker.js +3 -1
  47. package/build/tsconfig.tsbuildinfo +1 -1
  48. package/package.json +5 -5
  49. package/templates/blank/cargo.ts +17 -22
  50. package/templates/full/README.md +7 -4
  51. package/templates/full/agents/sdr.ts +12 -8
  52. package/templates/full/connectors/hunter.ts +10 -0
  53. package/templates/full/mcp/crm.ts +9 -6
  54. package/templates/full/tools/enrich.ts +28 -9
@@ -1,19 +1,17 @@
1
1
  import { type Token } from "../core.js";
2
2
  import { type FolderRef } from "../refs.js";
3
- import { type AgentUse, type ConnectorActionSpec, type ToolUse } from "./actions.js";
4
- import { type ModelUse } from "./agent.js";
3
+ import { type AgentUse } from "./actions.js";
5
4
  import type { FolderHandle } from "./folder.js";
6
5
  export type McpServerSpec = {
7
6
  name?: string;
8
7
  description?: string;
9
- /** Tools the server exposes (become tool actions). */
10
- tools?: ToolUse[];
11
- /** Agents the server exposes (become agent actions). */
12
- agents?: AgentUse[];
13
- /** Connector actions the server exposes. */
14
- connectorActions?: ConnectorActionSpec[];
15
- /** Data models the server serves. */
16
- models?: ModelUse[];
8
+ /**
9
+ * Everything the server exposes, in one array — tools, agents, connector
10
+ * actions, and data models. Each entry is a handle (bare or `{ ref, …options }`):
11
+ * a `defineTool` / `defineAgent` / `defineModel` handle, or a connector action
12
+ * `connector.<actionSlug>`. See `AgentUse`.
13
+ */
14
+ uses?: AgentUse[];
17
15
  folder?: FolderHandle | FolderRef;
18
16
  };
19
17
  export type McpServerHandle = {
@@ -1 +1 @@
1
- {"version":3,"file":"mcpServer.d.ts","sourceRoot":"","sources":["../../../src/resources/mcpServer.ts"],"names":[],"mappings":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,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;CAChC,CAAC;AAEF,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,aAAa,GAClB,eAAe,CAiBjB"}
@@ -4,8 +4,7 @@
4
4
  // `CreateMcpServerPayload`. Uuid-only identity (no slug) — state-tracked.
5
5
  import { register, resourceId, token } from "../core.js";
6
6
  import { refUuid } from "../refs.js";
7
- import { normalizeConnectorActions, normalizeSubAgents, normalizeTools, } from "./actions.js";
8
- import { normalizeModels } from "./agent.js";
7
+ import { normalizeUses } from "./actions.js";
9
8
  export function defineMcpServer(slug, spec) {
10
9
  const id = resourceId("mcpServer", slug);
11
10
  register({
@@ -17,11 +16,9 @@ export function defineMcpServer(slug, spec) {
17
16
  name: spec.name === undefined ? toTitle(slug) : spec.name,
18
17
  description: spec.description === undefined ? null : spec.description,
19
18
  folderUuid: spec.folder === undefined ? undefined : refUuid(spec.folder),
20
- // resolved AiTypes.Action[] / Resource[] by the apply executor
21
- tools: normalizeTools(spec.tools),
22
- subAgents: normalizeSubAgents(spec.agents),
23
- connectorActions: normalizeConnectorActions(spec.connectorActions),
24
- models: normalizeModels(spec.models, true),
19
+ // `uses` splits into the four buckets the executor resolves →
20
+ // AiTypes.Action[] / Resource[].
21
+ ...normalizeUses(spec.uses),
25
22
  },
26
23
  });
27
24
  return { slug, uuid: token(id, "uuid"), resource: "mcpServer" };
@@ -1,5 +1,6 @@
1
+ import type { SegmentationTypes, StorageTypes } from "@cargo-ai/types";
1
2
  import { type Token } from "../core.js";
2
- import { type DatasetRef, type FolderRef } from "../refs.js";
3
+ import { type DatasetRef, type FolderRef, type ModelRef } from "../refs.js";
3
4
  import type { ConnectorHandle } from "./connector.js";
4
5
  import type { FolderHandle } from "./folder.js";
5
6
  export type ScheduleSpec = {
@@ -9,6 +10,33 @@ export type ScheduleSpec = {
9
10
  type: "dbt";
10
11
  jobId: string;
11
12
  };
13
+ export type UnificationColumnSpec = {
14
+ slug: string;
15
+ reference: string;
16
+ };
17
+ export type UnificationParentSpec = {
18
+ kind: "model";
19
+ columnSlug: string;
20
+ parent: ModelHandle | ModelRef;
21
+ } | {
22
+ kind: "reference";
23
+ columnSlug: string;
24
+ reference: string;
25
+ };
26
+ export type UnificationSpec = {
27
+ source: "integration";
28
+ } | {
29
+ source: "custom";
30
+ type: StorageTypes.ModelUnificationType;
31
+ uniqueColumns: UnificationColumnSpec[];
32
+ /** Columns exposed on the unified model (defaults to all). */
33
+ selectedColumnSlugs?: string[];
34
+ /** Column carrying the event timestamp (event unification types only). */
35
+ timeColumnSlug?: string;
36
+ parent?: UnificationParentSpec;
37
+ /** Restrict which rows take part in unification (defaults to all rows). */
38
+ filter?: SegmentationTypes.Filter;
39
+ };
12
40
  export interface ExtractorConfigs {
13
41
  }
14
42
  type ExtractorConfigFor<S extends string, E extends string> = S extends keyof ExtractorConfigs ? E extends keyof ExtractorConfigs[S] ? ExtractorConfigs[S][E] : Record<string, unknown> : Record<string, unknown>;
@@ -23,6 +51,13 @@ export type ModelSpec<S extends string = string, E extends string = string> = {
23
51
  config?: ExtractorConfigFor<S, E>;
24
52
  schedule?: ScheduleSpec;
25
53
  folder?: FolderHandle | FolderRef;
54
+ /**
55
+ * How this model participates in unification. Omit to keep the source's
56
+ * default (a connector model defaults to its integration's mapping). Applied
57
+ * via an update once the model exists, so it also covers models the deploy
58
+ * adopts.
59
+ */
60
+ unification?: UnificationSpec;
26
61
  };
27
62
  export type ModelHandle = {
28
63
  readonly slug: string;
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/resources/model.ts"],"names":[],"mappings":"AAYA,OAAO,EAAwB,KAAK,KAAK,EAAS,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAW,MAAM,YAAY,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAUnC,MAAM,WAAW,gBAAgB;CAAG;AAEpC,KAAK,kBAAkB,CACrB,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,MAAM,IACd,CAAC,SAAS,MAAM,gBAAgB,GAChC,CAAC,SAAS,MAAM,gBAAgB,CAAC,CAAC,CAAC,GACjC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACzB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5B,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iFAAiF;IACjF,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC;IACzC,0EAA0E;IAC1E,WAAW,EAAE,CAAC,CAAC;IACf,4EA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W,EAAE,CAAC,CAAC;IACf,4EAA4E;IAC5E,MAAM,CAAC,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,MAAM,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IAClC;;;;;OAKG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B,CAAC;AAQF,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAC5D,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GACpB,WAAW,CAsBb"}
@@ -10,7 +10,7 @@
10
10
  //
11
11
  // Compiles to the storage `CreateModelPayload` once tokens are resolved.
12
12
  import { register, resourceId, token } from "../core.js";
13
- import { refUuid } from "../refs.js";
13
+ import { refUuid, } from "../refs.js";
14
14
  // A connector handle references its auto-created dataset (`.datasetUuid`); a
15
15
  // `datasetRef` references the dataset directly (`.uuid`).
16
16
  function datasetUuidOf(dataset) {
@@ -31,10 +31,47 @@ export function defineModel(slug, spec) {
31
31
  config: spec.config === undefined ? {} : spec.config,
32
32
  schedule: spec.schedule,
33
33
  folderUuid: spec.folder === undefined ? undefined : refUuid(spec.folder),
34
+ unification: spec.unification === undefined
35
+ ? undefined
36
+ : compileUnification(spec.unification),
34
37
  },
35
38
  });
36
39
  return { slug, uuid: token(id, "uuid"), resource: "model" };
37
40
  }
41
+ // Lower a `UnificationSpec` to the wire shape `StorageTypes.ModelUnification`.
42
+ // The only reshaping is the parent link: a `model` parent carries a handle/ref
43
+ // in code (so the dependency shows up in the graph), which becomes a
44
+ // `parentModelUuid` token resolved at apply time.
45
+ function compileUnification(unification) {
46
+ if (unification.source === "integration") {
47
+ return { source: "integration" };
48
+ }
49
+ return {
50
+ source: "custom",
51
+ type: unification.type,
52
+ uniqueColumns: unification.uniqueColumns,
53
+ selectedColumnSlugs: unification.selectedColumnSlugs,
54
+ timeColumnSlug: unification.timeColumnSlug,
55
+ parent: unification.parent === undefined
56
+ ? undefined
57
+ : compileUnificationParent(unification.parent),
58
+ filter: unification.filter,
59
+ };
60
+ }
61
+ function compileUnificationParent(parent) {
62
+ if (parent.kind === "model") {
63
+ return {
64
+ kind: "model",
65
+ columnSlug: parent.columnSlug,
66
+ parentModelUuid: refUuid(parent.parent),
67
+ };
68
+ }
69
+ return {
70
+ kind: "reference",
71
+ columnSlug: parent.columnSlug,
72
+ reference: parent.reference,
73
+ };
74
+ }
38
75
  function toTitle(slug) {
39
76
  return slug
40
77
  .split(/[-_]/)
@@ -0,0 +1,21 @@
1
+ import { type Token } from "../core.js";
2
+ import { type ModelRef } from "../refs.js";
3
+ import type { ModelHandle } from "./model.js";
4
+ export type RelationshipRelation = "oneToOne" | "oneToMany" | "manyToOne";
5
+ export type RelationshipEndpointSpec = {
6
+ model: ModelHandle | ModelRef;
7
+ column: string;
8
+ property?: string;
9
+ };
10
+ export type RelationshipSpec = {
11
+ from: RelationshipEndpointSpec;
12
+ to: RelationshipEndpointSpec;
13
+ relation: RelationshipRelation;
14
+ };
15
+ export type RelationshipHandle = {
16
+ readonly slug: string;
17
+ readonly uuid: Token;
18
+ readonly resource: "relationship";
19
+ };
20
+ export declare function defineRelationship(slug: string, spec: RelationshipSpec): RelationshipHandle;
21
+ //# sourceMappingURL=relationship.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relationship.d.ts","sourceRoot":"","sources":["../../../src/resources/relationship.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAwB,KAAK,KAAK,EAAS,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,KAAK,QAAQ,EAAW,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,MAAM,oBAAoB,GAAG,UAAU,GAAG,WAAW,GAAG,WAAW,CAAC;AAK1E,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,wBAAwB,CAAC;IAC/B,EAAE,EAAE,wBAAwB,CAAC;IAC7B,QAAQ,EAAE,oBAAoB,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;CACnC,CAAC;AAEF,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,gBAAgB,GACrB,kBAAkB,CAmBpB"}
@@ -0,0 +1,39 @@
1
+ // defineRelationship — a join between two data models in the SAME dataset (a
2
+ // `StorageTypes.Relationship`). It links a column on a `from` model to a column
3
+ // on a `to` model with a cardinality (`oneToOne` / `oneToMany` / `manyToOne`),
4
+ // optionally navigating into a JSON column via a property slug:
5
+ //
6
+ // const accounts = defineModel("accounts", { ... });
7
+ // const contacts = defineModel("contacts", { ... });
8
+ // defineRelationship("contact-account", {
9
+ // from: { model: contacts, column: "account_id" },
10
+ // to: { model: accounts, column: "id" },
11
+ // relation: "manyToOne",
12
+ // });
13
+ //
14
+ // Both models must live in the same dataset (the server derives the dataset from
15
+ // the `from` model at deploy). Relationships have no server-side slug, so the
16
+ // `slug` is a local identifier only; identity is tracked by the state uuid. The
17
+ // backend `set` endpoint is a per-dataset declarative replace, so the executor
18
+ // read-merges the dataset's live relationships around this one.
19
+ import { register, resourceId, token } from "../core.js";
20
+ import { refUuid } from "../refs.js";
21
+ export function defineRelationship(slug, spec) {
22
+ const id = resourceId("relationship", slug);
23
+ register({
24
+ id,
25
+ kind: "relationship",
26
+ slug,
27
+ spec: {
28
+ slug,
29
+ fromModelUuid: refUuid(spec.from.model),
30
+ fromColumnSlug: spec.from.column,
31
+ fromPropertySlug: spec.from.property === undefined ? null : spec.from.property,
32
+ toModelUuid: refUuid(spec.to.model),
33
+ toColumnSlug: spec.to.column,
34
+ toPropertySlug: spec.to.property === undefined ? null : spec.to.property,
35
+ relation: spec.relation,
36
+ },
37
+ });
38
+ return { slug, uuid: token(id, "uuid"), resource: "relationship" };
39
+ }
@@ -1,12 +1,24 @@
1
- import { type Token } from "../core.js";
1
+ import { type SecretRef, type Token } from "../core.js";
2
2
  import { type FolderRef } from "../refs.js";
3
3
  import type { FolderHandle } from "./folder.js";
4
+ export type WorkerTrigger = {
5
+ name?: string;
6
+ description?: string;
7
+ cron: string;
8
+ path: string;
9
+ method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
10
+ data?: Record<string, unknown>;
11
+ headers?: Record<string, string>;
12
+ };
4
13
  export type WorkerSpec = {
5
14
  /** Path to the worker's code directory (uploaded + built on deploy). */
6
15
  path: string;
7
16
  name?: string;
8
17
  description?: string;
9
18
  folder?: FolderHandle | FolderRef;
19
+ triggers?: WorkerTrigger[];
20
+ /** Env vars baked into the build. Use `secret("NAME")` for secret values. */
21
+ env?: Record<string, string | SecretRef>;
10
22
  };
11
23
  export type WorkerHandle = {
12
24
  readonly slug: string;
@@ -1 +1 @@
1
- {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../src/resources/worker.ts"],"names":[],"mappings":"AAKA,OAAO,EAAwB,KAAK,KAAK,EAAS,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,KAAK,SAAS,EAAW,MAAM,YAAY,CAAC;AAErD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CA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,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;IAC3B,6EAA6E;IAC7E,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,2DAA2D;IAC3D,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC;CACrB,CAAC;AAEF,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,YAAY,CAoBzE"}
@@ -2,7 +2,7 @@
2
2
  // directory. Distinct from @cargo-ai/worker-sdk's `createWorker`, which is the
3
3
  // worker's *runtime code* (the Hono app at <path>/src/index.ts). On deploy the
4
4
  // reconciler creates the worker slot, uploads the bundle, and promotes it.
5
- import { register, resourceId, token } from "../core.js";
5
+ import { register, resourceId, token, } from "../core.js";
6
6
  import { refUuid } from "../refs.js";
7
7
  import { assertBundleFiles, bundleHash } from "./bundle.js";
8
8
  // Files the hosting worker build always requires at the bundle root: a manifest
@@ -35,6 +35,8 @@ export function defineWorker(slug, spec) {
35
35
  // hash the code now so editing it shows as drift on the next deploy
36
36
  contentHash: bundleHash(spec.path),
37
37
  folderUuid: spec.folder === undefined ? undefined : refUuid(spec.folder),
38
+ triggers: spec.triggers === undefined ? [] : spec.triggers,
39
+ env: spec.env === undefined ? {} : spec.env,
38
40
  },
39
41
  });
40
42
  return { slug, uuid: token(id, "uuid"), url: token(id, "url") };