@notionhq/apps 0.0.18 → 0.0.20

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 +22 -1
  2. package/dist/cli/build.d.ts.map +1 -1
  3. package/dist/cli/build.js +12 -7
  4. package/dist/cli/emit-manifest.d.ts +1 -1
  5. package/dist/cli/emit-manifest.d.ts.map +1 -1
  6. package/dist/cli/emit-manifest.js +66 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +3 -1
  10. package/dist/notion-as-code/custom-agent.d.ts +1 -0
  11. package/dist/notion-as-code/custom-agent.d.ts.map +1 -1
  12. package/dist/notion-as-code/custom-agent.js +1 -1
  13. package/dist/notion-as-code/database.d.ts +2 -0
  14. package/dist/notion-as-code/database.d.ts.map +1 -1
  15. package/dist/notion-as-code/database.js +3 -0
  16. package/dist/notion-as-code/date.d.ts +3 -2
  17. package/dist/notion-as-code/date.d.ts.map +1 -1
  18. package/dist/notion-as-code/handles.d.ts +8 -11
  19. package/dist/notion-as-code/handles.d.ts.map +1 -1
  20. package/dist/notion-as-code/handles.js +8 -7
  21. package/dist/notion-as-code/index.d.ts +8 -11
  22. package/dist/notion-as-code/index.d.ts.map +1 -1
  23. package/dist/notion-as-code/page.d.ts +50 -1
  24. package/dist/notion-as-code/page.d.ts.map +1 -1
  25. package/dist/notion-as-code/page.js +1 -0
  26. package/dist/notion-as-code/page.test.d.ts +2 -0
  27. package/dist/notion-as-code/page.test.d.ts.map +1 -0
  28. package/dist/workflow-access-types.test.d.ts +2 -0
  29. package/dist/workflow-access-types.test.d.ts.map +1 -0
  30. package/dist/workflow-access.d.ts +68 -0
  31. package/dist/workflow-access.d.ts.map +1 -0
  32. package/dist/workflow-access.js +135 -0
  33. package/dist/workflow.d.ts +17 -6
  34. package/dist/workflow.d.ts.map +1 -1
  35. package/dist/workflow.js +8 -1
  36. package/docs/BUILD.md +38 -4
  37. package/package.json +1 -1
  38. package/skills/notion-as-code/SKILL.md +16 -3
  39. package/skills/workflow/SKILL.md +53 -16
  40. package/src/cli/build.test.ts +24 -0
  41. package/src/cli/build.ts +13 -8
  42. package/src/cli/emit-manifest.ts +107 -0
  43. package/src/index.ts +20 -1
  44. package/src/notion-as-code/custom-agent.ts +2 -1
  45. package/src/notion-as-code/database.ts +5 -0
  46. package/src/notion-as-code/date.ts +4 -2
  47. package/src/notion-as-code/handles.ts +16 -12
  48. package/src/notion-as-code/index.ts +10 -1
  49. package/src/notion-as-code/page.test.ts +35 -0
  50. package/src/notion-as-code/page.ts +62 -2
  51. package/src/workflow-access-types.test.ts +69 -0
  52. package/src/workflow-access.ts +299 -0
  53. package/src/workflow.test.ts +112 -0
  54. package/src/workflow.ts +50 -7
package/README.md CHANGED
@@ -23,8 +23,12 @@ Import the helpers your app uses:
23
23
 
24
24
  ```ts
25
25
  import { page, workflow } from "@notionhq/apps";
26
+ import { notion } from "@notionhq/apps/notion-as-code";
26
27
 
27
- const home = page({ resourceId: "home" });
28
+ const home = page({
29
+ resourceId: "home",
30
+ properties: { title: notion.text("App home") },
31
+ });
28
32
 
29
33
  export default workflow({
30
34
  name: "Follow up",
@@ -108,6 +112,23 @@ Use `context.notion` for Notion API calls. Deployed apps receive Notion API
108
112
  credentials automatically, so do not configure or push `NOTION_API_TOKEN`.
109
113
  Local execution needs the token in `.env` before making a Notion API request.
110
114
 
115
+ For a resource declared with Notion as Code, add a named runtime binding with
116
+ `access: { handbook: { resource: handbook, level: "view" } }`. Cloud deployment
117
+ resolves the declaration's NaC `resourceId` to a live ID and exposes it to the
118
+ handler as `context.access.handbook.id`. Deployment also reconciles the declared
119
+ access through the existing Notion-module permissions. Those permissions, not
120
+ the bindings, authorize `context.notion` calls.
121
+
122
+ Resources granted to the workflow in Notion's UI do not need an `access` entry, a
123
+ NaC declaration, or a NaC `resourceId`. Pass the live record ID directly to the
124
+ appropriate `context.notion` call, for example
125
+ `context.notion.pages.retrieve({ page_id: "page-id" })`; the call remains subject
126
+ to the existing workflow permissions. UI grants do not create `context.access`
127
+ aliases. Pages, databases, data sources, and custom agents are supported by
128
+ named bindings. Workflows with nonempty `access` cannot use `--local-build`.
129
+ See the [workflow skill](./skills/workflow/SKILL.md#resources-created-with-the-app)
130
+ for access levels and a complete example.
131
+
111
132
  ## Data-source syncs
112
133
 
113
134
  Declare a database with Notion as Code, then pass one of its data-source handles to `sync`:
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/cli/build.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAUlD,MAAM,MAAM,WAAW,GAAG;IACzB,QAAQ,EAAE,WAAW,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAwCxE"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/cli/build.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAUlD,MAAM,MAAM,WAAW,GAAG;IACzB,QAAQ,EAAE,WAAW,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CA8CxE"}
package/dist/cli/build.js CHANGED
@@ -30,18 +30,23 @@ async function buildApp(projectRoot) {
30
30
  await bundle.close();
31
31
  }
32
32
  const blockConfigs = await buildBlockDeclarations(projectRoot, capabilities);
33
- const manifest = await extractManifest(bundlePath, capabilities, blockConfigs);
34
- const manifestPath = path.join(projectRoot, "dist", "manifest.json");
35
- await fs.promises.writeFile(manifestPath, `${JSON.stringify(manifest, null, " ")}
36
- `);
37
- await emitProvisioningArtifact(
33
+ const entityProvisioning = await buildMetadata(
38
34
  projectRoot,
39
35
  capabilities.filter((capability) => capability.runtime === "worker")
40
36
  );
37
+ const manifest = await extractManifest(
38
+ bundlePath,
39
+ capabilities,
40
+ blockConfigs,
41
+ entityProvisioning
42
+ );
43
+ const manifestPath = path.join(projectRoot, "dist", "manifest.json");
44
+ await fs.promises.writeFile(manifestPath, `${JSON.stringify(manifest, null, " ")}
45
+ `);
46
+ await emitProvisioningArtifact(projectRoot, entityProvisioning);
41
47
  return { manifest, bundlePath, manifestPath };
42
48
  }
43
- async function emitProvisioningArtifact(projectRoot, capabilities) {
44
- const entityProvisioning = await buildMetadata(projectRoot, capabilities);
49
+ async function emitProvisioningArtifact(projectRoot, entityProvisioning) {
45
50
  const provisioningPath = path.join(projectRoot, "dist", "provisioning.json");
46
51
  if (entityProvisioning.intents.length === 0) {
47
52
  await fs.promises.rm(provisioningPath, { force: true });
@@ -2,7 +2,7 @@ import { type RecordedProvisioning } from "../notion-as-code/provisioning.js";
2
2
  import type { AppManifest } from "../manifest.js";
3
3
  import type { DiscoveredCapability } from "./discover.js";
4
4
  /** Extract the app manifest from a built bundle. */
5
- export declare function extractManifest(bundlePath: string, capabilities: readonly DiscoveredCapability[], blockConfigs?: Record<string, unknown>): Promise<AppManifest>;
5
+ export declare function extractManifest(bundlePath: string, capabilities: readonly DiscoveredCapability[], blockConfigs?: Record<string, unknown>, provisioning?: RecordedProvisioning): Promise<AppManifest>;
6
6
  /** Import the metadata bundle and return the provisioning declarations it recorded. */
7
7
  export declare function extractProvisioning(bundlePath: string): Promise<RecordedProvisioning>;
8
8
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"emit-manifest.d.ts","sourceRoot":"","sources":["../../src/cli/emit-manifest.ts"],"names":[],"mappings":"AAMA,OAAO,EAEN,KAAK,oBAAoB,EACzB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,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;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAoCjE;AAED,yFAAyF;AACzF,wBAAsB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAE9F"}
@@ -162,7 +162,7 @@ class DatabaseCollector {
162
162
  });
163
163
  }
164
164
  }
165
- async function extractManifest(bundlePath, capabilities, blockConfigs = {}) {
165
+ async function extractManifest(bundlePath, capabilities, blockConfigs = {}, provisioning) {
166
166
  clearRegisteredPacers();
167
167
  const bundle = await importBundle(bundlePath);
168
168
  const registry = getCapabilityRegistry(bundle);
@@ -198,6 +198,9 @@ async function extractManifest(bundlePath, capabilities, blockConfigs = {}) {
198
198
  const { database: _database, ...rest } = config;
199
199
  config = { ...rest, databaseKey };
200
200
  }
201
+ if (capability.type === "workflow") {
202
+ validateWorkflowAccessReferences(config.access, provisioning, capability.sourcePath);
203
+ }
201
204
  assertJsonSafe(config, `${capability.sourcePath} config`);
202
205
  return { type: capability.type, key: capability.key, config };
203
206
  });
@@ -226,6 +229,68 @@ async function extractManifest(bundlePath, capabilities, blockConfigs = {}) {
226
229
  }
227
230
  return manifest;
228
231
  }
232
+ const WORKFLOW_ACCESS_TYPES = {
233
+ page: true,
234
+ database: true,
235
+ dataSource: true,
236
+ customAgent: true
237
+ };
238
+ const WORKFLOW_ACCESS_LEVELS = {
239
+ view: true,
240
+ comment: true,
241
+ edit: true,
242
+ fullAccess: true
243
+ };
244
+ function validateWorkflowAccessReferences(access, provisioning, capabilityPath) {
245
+ if (access === void 0) return;
246
+ if (typeof access !== "object" || access === null || Array.isArray(access) || provisioning === void 0 && Object.keys(access).length > 0) {
247
+ throw new Error(
248
+ `${capabilityPath}: workflow access must reference resources recorded by the current build`
249
+ );
250
+ }
251
+ if (provisioning === void 0) {
252
+ return;
253
+ }
254
+ const accessObject = access;
255
+ const aliases = Object.keys(accessObject);
256
+ if (Reflect.ownKeys(accessObject).length !== aliases.length) {
257
+ throw new Error(`${capabilityPath}: workflow access aliases must be enumerable strings`);
258
+ }
259
+ for (const alias of aliases) {
260
+ if (!/^[a-zA-Z][a-zA-Z0-9_-]{0,127}$/.test(alias) || alias === "__proto__" || alias === "prototype" || alias === "constructor") {
261
+ throw new Error(`${capabilityPath}: invalid workflow access alias "${alias}"`);
262
+ }
263
+ const requirement = accessObject[alias];
264
+ if (typeof requirement !== "object" || requirement === null || Array.isArray(requirement) || Reflect.ownKeys(requirement).length !== 3 || !Object.hasOwn(requirement, "type") || !Object.hasOwn(requirement, "resourceId") || !Object.hasOwn(requirement, "level")) {
265
+ throw new Error(`${capabilityPath}: invalid workflow access requirement "${alias}"`);
266
+ }
267
+ const requirementObject = requirement;
268
+ const type = requirementObject.type;
269
+ const resourceId = requirementObject.resourceId;
270
+ const level = requirementObject.level;
271
+ if (typeof type !== "string" || !Object.hasOwn(WORKFLOW_ACCESS_TYPES, type) || typeof resourceId !== "string" || resourceId.length === 0 || typeof level !== "string" || (type === "customAgent" ? level !== "call" : !Object.hasOwn(WORKFLOW_ACCESS_LEVELS, level))) {
272
+ throw new Error(`${capabilityPath}: invalid workflow access requirement "${alias}"`);
273
+ }
274
+ if (!provisioning.intents.some((intent) => {
275
+ switch (type) {
276
+ case "page":
277
+ return intent.type === "page" && intent.resourceId === resourceId;
278
+ case "database":
279
+ return intent.type === "database" && intent.resourceId === resourceId;
280
+ case "customAgent":
281
+ return intent.type === "custom_agent" && intent.resourceId === resourceId;
282
+ case "dataSource":
283
+ return intent.type === "database" && (intent.dataSources ?? []).some(
284
+ (dataSource) => dataSource.resourceId === resourceId
285
+ );
286
+ }
287
+ })) {
288
+ throw new Error(
289
+ `${capabilityPath}: workflow access "${alias}" references ${type} "${resourceId}" that is not declared by the current build`
290
+ );
291
+ }
292
+ }
293
+ }
229
294
  async function extractProvisioning(bundlePath) {
230
295
  const bundle = await importBundle(bundlePath);
231
296
  if (typeof bundle !== "object" || bundle === null || !("default" in bundle) || !isRecordedProvisioning(bundle.default)) {
package/dist/index.d.ts CHANGED
@@ -5,6 +5,6 @@ export { page } from "./notion-as-code/page.js";
5
5
  export { teamspace } from "./notion-as-code/teamspace.js";
6
6
  export { view } from "./notion-as-code/view.js";
7
7
  export { sync } from "./sync.js";
8
- export { workflow } from "./workflow.js";
8
+ export { workflow, type Workflow, type WorkflowAccess, type WorkflowAccessAgentLevel, type WorkflowAccessBindings, type WorkflowAccessDeclaration, type WorkflowAccessDeclarations, type WorkflowAccessLevel, type WorkflowAccessLevelFor, type WorkflowAccessResource, type WorkflowAccessResourceLevel, type WorkflowAccessResourceType, type WorkflowAccessRequirement, type WorkflowAccessRequirements, type WorkflowAccessValue, type WorkflowConfiguration, type WorkflowContext, type WorkflowTriggerConfiguration, } from "./workflow.js";
9
9
  export type { WorkflowState, WorkflowStateValue } from "./workflow-state.js";
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACN,QAAQ,EACR,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,4BAA4B,GACjC,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -5,7 +5,9 @@ import { page } from "./notion-as-code/page.js";
5
5
  import { teamspace } from "./notion-as-code/teamspace.js";
6
6
  import { view } from "./notion-as-code/view.js";
7
7
  import { sync } from "./sync.js";
8
- import { workflow } from "./workflow.js";
8
+ import {
9
+ workflow
10
+ } from "./workflow.js";
9
11
  export {
10
12
  customAgent,
11
13
  customBlock,
@@ -11,6 +11,7 @@ export type CustomAgentArgs = {
11
11
  triggers?: readonly unknown[];
12
12
  };
13
13
  export type CustomAgentHandle = {
14
+ readonly resourceType: "customAgent";
14
15
  readonly resourceId: string;
15
16
  };
16
17
  /** Declare a custom agent and validate every shared resource reference. */
@@ -1 +1 @@
1
- {"version":3,"file":"custom-agent.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/custom-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,gBAAgB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAIpF,MAAM,MAAM,eAAe,GAAG;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC,gBAAgB,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,oBAAoB,GAAG,oBAAoB,GAAG,sBAAsB,CAAC;IAC7E,eAAe,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IAExC,QAAQ,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,2EAA2E;AAC3E,wBAAgB,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,iBAAiB,CASpE"}
1
+ {"version":3,"file":"custom-agent.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/custom-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,gBAAgB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAIpF,MAAM,MAAM,eAAe,GAAG;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC,gBAAgB,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,oBAAoB,GAAG,oBAAoB,GAAG,sBAAsB,CAAC;IAC7E,eAAe,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IAExC,QAAQ,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC/B,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,2EAA2E;AAC3E,wBAAgB,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,iBAAiB,CASpE"}
@@ -6,7 +6,7 @@ function customAgent(args) {
6
6
  assertUserResourceId(resourceId);
7
7
  }
8
8
  recordIntent({ type: "custom_agent", ...args });
9
- return { resourceId: args.resourceId };
9
+ return { resourceType: "customAgent", resourceId: args.resourceId };
10
10
  }
11
11
  export {
12
12
  customAgent
@@ -70,12 +70,14 @@ export type DatabaseArgs<Schema extends NotionAsCodeSchema = NotionAsCodeSchema,
70
70
  export type ChildDatabaseArgs<Schema extends NotionAsCodeSchema = NotionAsCodeSchema, DataSources extends DataSourceMap = DataSourceMap> = ChildSingleSourceDatabaseArgs<Schema> | ChildMultiSourceDatabaseArgs<DataSources> | Omit<ViewOnlyDatabaseArgs, "parent">;
71
71
  /** A source handle retains its keyed authoring schema for sync inference. */
72
72
  export type DataSourceHandle<Schema extends NotionAsCodeSchema = NotionAsCodeSchema> = {
73
+ readonly resourceType: "dataSource";
73
74
  readonly resourceId: string;
74
75
  readonly schema: Schema;
75
76
  readonly database: Database<AppsSchemaForSchema<Schema>>;
76
77
  addPage: (args: ChildPageArgs) => PageHandle;
77
78
  };
78
79
  type DatabaseHandleBase = {
80
+ readonly resourceType: "database";
79
81
  readonly resourceId: string;
80
82
  addView: (view: ViewSchema) => void;
81
83
  };
@@ -1 +1 @@
1
- {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAEN,KAAK,cAAc,EAEnB,KAAK,gBAAgB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databaseResourceId}" is missing its data source`);
54
54
  }
55
55
  return {
56
+ resourceType: "database",
56
57
  resourceId: databaseResourceId,
57
58
  dataSource,
58
59
  addView: handle.addView
@@ -151,6 +152,7 @@ function createDatabase(intent, sourceEntries) {
151
152
  }
152
153
  recordIntent({ ...intent, type: "database" });
153
154
  return {
155
+ resourceType: "database",
154
156
  resourceId: intent.resourceId,
155
157
  datasources: handles,
156
158
  addView(view) {
@@ -177,6 +179,7 @@ function createDataSourceHandle(dataSource, schema) {
177
179
  propertyNames.add(property.name);
178
180
  }
179
181
  return {
182
+ resourceType: "dataSource",
180
183
  resourceId: dataSource.resourceId,
181
184
  schema,
182
185
  database: createAppsDatabase(dataSource.resourceId, dataSource),
@@ -1,9 +1,10 @@
1
+ import type { TextValue } from "./page.js";
1
2
  /** Serialize Notion-as-Code date values for Apps property payloads. */
2
- export declare function date(startDate: string, endDate?: string): unknown[][];
3
+ export declare function date(startDate: string, endDate?: string): TextValue;
3
4
  /** Serialize Notion-as-Code datetime values for Apps property payloads. */
4
5
  export declare function datetime(value: {
5
6
  start: string;
6
7
  end?: string;
7
8
  timeZone?: string;
8
- }): unknown[][];
9
+ }): TextValue;
9
10
  //# sourceMappingURL=date.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/date.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,wBAAgB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,EAAE,EAAE,CAWrE;AAED,2EAA2E;AAC3E,wBAAgB,QAAQ,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,EAAE,EAAE,CA6B/F"}
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/date.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,uEAAuE;AACvE,wBAAgB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAWnE;AAED,2EAA2E;AAC3E,wBAAgB,QAAQ,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CA6B7F"}
@@ -1,7 +1,7 @@
1
1
  import { customAgent } from "./custom-agent.js";
2
2
  import { database } from "./database.js";
3
3
  import { date, datetime } from "./date.js";
4
- import { page } from "./page.js";
4
+ import { page, type TextValue, type VerificationInput, type VerificationPropertyValue } from "./page.js";
5
5
  import { teamspace } from "./teamspace.js";
6
6
  import { view } from "./view.js";
7
7
  declare const notionAsCodeFacade: {
@@ -10,22 +10,19 @@ declare const notionAsCodeFacade: {
10
10
  page: typeof page;
11
11
  customAgent: typeof customAgent;
12
12
  view: typeof view;
13
- text: (value: string) => string[][];
14
- number: (value: number) => string[][];
13
+ text: (value: string) => TextValue;
14
+ number: (value: number) => TextValue;
15
15
  date: typeof date;
16
16
  datetime: typeof datetime;
17
+ verification: (value: VerificationInput) => VerificationPropertyValue;
17
18
  select: (value: string) => string;
18
19
  status: (value: string) => string;
19
20
  multiSelect: (values: readonly string[]) => string;
20
- checkbox: (value: boolean) => string[][];
21
- url: (value: string) => (string | string[][])[][];
22
- email: (value: string) => (string | string[][])[][];
23
- phone: (value: string) => string[][];
21
+ checkbox: (value: boolean) => TextValue;
22
+ url: (value: string) => TextValue;
23
+ email: (value: string) => TextValue;
24
+ phone: (value: string) => TextValue;
24
25
  relation: (value: string | readonly string[]) => string | any[] | readonly string[];
25
- file: (resourceId: string) => {
26
- type: "file";
27
- resourceId: string;
28
- };
29
26
  };
30
27
  export type NotionAsCodeFacade = typeof notionAsCodeFacade;
31
28
  /** Create the runtime facade used to declare Notion-as-Code project metadata. */
@@ -1 +1 @@
1
- {"version":3,"file":"handles.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/handles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,QAAA,MAAM,kBAAkB;;;;;;kBAMT,MAAM;oBACJ,MAAM;;;oBAGN,MAAM;oBACN,MAAM;0BACA,SAAS,MAAM,EAAE;sBACrB,OAAO;iBACZ,MAAM;mBACJ,MAAM;mBACN,MAAM;sBACH,MAAM,GAAG,SAAS,MAAM,EAAE;uBACzB,MAAM;;;;CAIzB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAC;AAE3D,iFAAiF;AACjF,wBAAgB,YAAY,IAAI,kBAAkB,CAEjD"}
1
+ {"version":3,"file":"handles.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/handles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACN,IAAI,EACJ,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,QAAA,MAAM,kBAAkB;;;;;;kBAMT,MAAM,KAAG,SAAS;oBAChB,MAAM,KAAG,SAAS;;;0BAGZ,iBAAiB,KAAG,yBAAyB;oBAInD,MAAM;oBACN,MAAM;0BACA,SAAS,MAAM,EAAE;sBACrB,OAAO,KAAG,SAAS;iBACxB,MAAM,KAAG,SAAS;mBAChB,MAAM,KAAG,SAAS;mBAClB,MAAM,KAAG,SAAS;sBACf,MAAM,GAAG,SAAS,MAAM,EAAE;CAC5C,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAC;AAE3D,iFAAiF;AACjF,wBAAgB,YAAY,IAAI,kBAAkB,CAEjD"}
@@ -1,8 +1,9 @@
1
1
  import { customAgent } from "./custom-agent.js";
2
2
  import { database } from "./database.js";
3
3
  import { date, datetime } from "./date.js";
4
- import { page } from "./page.js";
5
- import { assertUserResourceId } from "./resource.js";
4
+ import {
5
+ page
6
+ } from "./page.js";
6
7
  import { teamspace } from "./teamspace.js";
7
8
  import { view } from "./view.js";
8
9
  const notionAsCodeFacade = {
@@ -15,6 +16,10 @@ const notionAsCodeFacade = {
15
16
  number: (value) => [[String(value)]],
16
17
  date,
17
18
  datetime,
19
+ verification: (value) => ({
20
+ ...value,
21
+ type: "verification"
22
+ }),
18
23
  select: (value) => value,
19
24
  status: (value) => value,
20
25
  multiSelect: (values) => values.join(","),
@@ -22,11 +27,7 @@ const notionAsCodeFacade = {
22
27
  url: (value) => [[value, [["a", value]]]],
23
28
  email: (value) => [[value, [["a", `mailto:${value}`]]]],
24
29
  phone: (value) => [[value]],
25
- relation: (value) => Array.isArray(value) ? [...value] : value,
26
- file: (resourceId) => {
27
- assertUserResourceId(resourceId);
28
- return { type: "file", resourceId };
29
- }
30
+ relation: (value) => Array.isArray(value) ? [...value] : value
30
31
  };
31
32
  function createNotion() {
32
33
  return notionAsCodeFacade;
@@ -2,7 +2,7 @@ export { APPS_RESERVED_RESOURCE_ID_PREFIX, APPS_WORKSPACE_RESOURCE_ID } from "./
2
2
  export type { DatabaseIntent, DataSourceDefinition, NotionAsCodeIcon, NotionAsCodeProperty, NotionAsCodePropertyConfig, NotionAsCodeSchema, NotionAsCodeSelectOption, NotionAsCodeStatusOption, Parent, ResourceId, } from "./intents.js";
3
3
  export type { CustomAgentArgs, CustomAgentHandle } from "./custom-agent.js";
4
4
  export type { ChildDatabaseArgs, ChildDatabaseFactory, ChildMultiSourceDatabaseArgs, ChildSingleSourceDatabaseArgs, DataSourceArgs, DataSourceHandle, DataSourceMap, DatabaseArgs, DatabaseHandle, MultiSourceDatabaseArgs, SingleSourceDatabaseArgs, SingleSourceDatabaseHandle, } from "./database.js";
5
- export type { ChildPageArgs, PageArgs, PageHandle } from "./page.js";
5
+ export type { ChildPageArgs, PageArgs, PageHandle, PropertyValue, SimpleTextToken, TextValue, VerificationInput, VerificationPropertyValue, } from "./page.js";
6
6
  export type { TeamspaceArgs, TeamspaceHandle } from "./teamspace.js";
7
7
  export type { ViewArgs, ViewHandle } from "./view.js";
8
8
  export type { AdvancedFilterSchema, BasePropertyFilter, BaseViewSchema, BoardViewSchema, CalendarViewSchema, CheckboxGroupByFormat, CheckboxPropertyFilter, CoverAspectFormat, CoverFormat, CoverSizeFormat, DatabaseViewSortDirection, DateFilterMode, DateGroupByFormat, DatePropertyFilter, DatePropertyFilterValue, DatePropertyTypes, ExactDatePropertyFilterValue, ExactRangeDatePropertyFilterValue, FeedViewSchema, FilterSchema, FormulaGroupByFormat, GalleryViewSchema, GroupByFormat, GroupByFormatBase, GroupFormat, ListViewSchema, LocationGroupByFormat, MultiSelectPropertyFilter, NumberGroupByFormat, NumberPropertyFilter, PersonGroupByFormat, PersonPropertyFilter, PropertyFilterSchema, PropertyFormat, PropertyViewSortSchema, PropertyVisibility, RelationGroupByFormat, RelationPropertyFilter, RelativeDatePreset, RelativeDatePropertyFilterValue, RelativeDateRangeUnit, RelativeToTodayDatePropertyFilterValue, SelectGroupByFormat, SelectPropertyFilter, StatusGroupByFormat, StatusPropertyFilter, TableViewSchema, TextGroupByFormat, TextPropertyFilter, TimelineViewSchema, ViewSchema, ViewType, } from "./views.js";
@@ -13,21 +13,18 @@ export declare const notion: {
13
13
  page: typeof import("./page.js").page;
14
14
  customAgent: typeof import("./custom-agent.js").customAgent;
15
15
  view: typeof import("./view.js").view;
16
- text: (value: string) => string[][];
17
- number: (value: number) => string[][];
16
+ text: (value: string) => import("./page.js").TextValue;
17
+ number: (value: number) => import("./page.js").TextValue;
18
18
  date: typeof import("./date.js").date;
19
19
  datetime: typeof import("./date.js").datetime;
20
+ verification: (value: import("./page.js").VerificationInput) => import("./page.js").VerificationPropertyValue;
20
21
  select: (value: string) => string;
21
22
  status: (value: string) => string;
22
23
  multiSelect: (values: readonly string[]) => string;
23
- checkbox: (value: boolean) => string[][];
24
- url: (value: string) => (string | string[][])[][];
25
- email: (value: string) => (string | string[][])[][];
26
- phone: (value: string) => string[][];
24
+ checkbox: (value: boolean) => import("./page.js").TextValue;
25
+ url: (value: string) => import("./page.js").TextValue;
26
+ email: (value: string) => import("./page.js").TextValue;
27
+ phone: (value: string) => import("./page.js").TextValue;
27
28
  relation: (value: string | readonly string[]) => string | any[] | readonly string[];
28
- file: (resourceId: string) => {
29
- type: "file";
30
- resourceId: string;
31
- };
32
29
  };
33
30
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gCAAgC,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAC5F,YAAY,EACX,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,0BAA0B,EAC1B,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,EACxB,MAAM,EACN,UAAU,GACV,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;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":"index.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gCAAgC,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAC5F,YAAY,EACX,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,0BAA0B,EAC1B,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,EACxB,MAAM,EACN,UAAU,GACV,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,YAAY,EACX,iBAAiB,EACjB,oBAAoB,EACpB,4BAA4B,EAC5B,6BAA6B,EAC7B,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,cAAc,EACd,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,GAC1B,MAAM,eAAe,CAAC;AACvB,YAAY,EACX,aAAa,EACb,QAAQ,EACR,UAAU,EACV,aAAa,EACb,eAAe,EACf,SAAS,EACT,iBAAiB,EACjB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACrE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACtD,YAAY,EACX,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,yBAAyB,EACzB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,iBAAiB,EACjB,4BAA4B,EAC5B,iCAAiC,EACjC,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,+BAA+B,EAC/B,qBAAqB,EACrB,sCAAsC,EACtC,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,EACV,QAAQ,GACR,MAAM,YAAY,CAAC;AAEpB,wEAAwE;AACxE,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;CAAiB,CAAC"}
@@ -1,16 +1,65 @@
1
1
  import { type Parent, type ResourceId } from "./intents.js";
2
2
  import { type ChildDatabaseFactory } from "./database.js";
3
+ /**
4
+ * A single text token: plain text as `[string]`, or text with annotations as
5
+ * `[string, ...annotations]`.
6
+ */
7
+ export type SimpleTextToken = [string] | [string, ...unknown[]];
8
+ /**
9
+ * The JSON-serializable text format returned by Notion-as-Code text helpers.
10
+ */
11
+ export type TextValue = SimpleTextToken[];
12
+ export type VerificationInput = {
13
+ state: "verified";
14
+ /** Set an expiration with `notion.datetime(...)`; omit it for indefinite verification. */
15
+ datetime?: TextValue;
16
+ } | {
17
+ state: "unverified";
18
+ };
19
+ export type VerificationPropertyValue = VerificationInput & {
20
+ type: "verification";
21
+ };
22
+ /**
23
+ * A page property value accepted by Notion as Code.
24
+ *
25
+ * Use helpers from `@notionhq/apps/notion-as-code` to construct rich values
26
+ * such as text, dates, checkboxes, and URLs.
27
+ */
28
+ export type PropertyValue = string | number | TextValue | string[] | VerificationPropertyValue | undefined;
29
+ /**
30
+ * Arguments for declaring a page.
31
+ *
32
+ * For a regular page, set its title through
33
+ * `properties.title: notion.text("My Page Title")`. For a database page, use
34
+ * the title property's schema name instead of `title`.
35
+ */
3
36
  export type PageArgs = {
4
37
  resourceId: ResourceId;
5
38
  /** Omit to create a private top-level page in the Apps workspace. */
6
39
  parent?: Parent;
7
40
  cover?: unknown;
8
- properties?: Record<string, unknown>;
41
+ /**
42
+ * Page properties, including the page title.
43
+ *
44
+ * @example Regular page
45
+ * properties: { title: notion.text("My Page Title") }
46
+ *
47
+ * @example Database page
48
+ * properties: { Name: notion.text("Task Name"), Status: "In Progress" }
49
+ */
50
+ properties?: Record<string, PropertyValue | undefined>;
51
+ /**
52
+ * Page body in Notion-flavored Markdown.
53
+ *
54
+ * Markdown headings create child blocks. They do not set the page title;
55
+ * set a regular page's title with `properties.title`.
56
+ */
9
57
  content?: string;
10
58
  fullWidth?: boolean;
11
59
  };
12
60
  export type ChildPageArgs = Omit<PageArgs, "parent">;
13
61
  export type PageHandle = {
62
+ readonly resourceType: "page";
14
63
  readonly resourceId: string;
15
64
  addDatabase: ChildDatabaseFactory;
16
65
  addPage: (args: ChildPageArgs) => PageHandle;
@@ -1 +1 @@
1
- {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/page.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,MAAM,EACX,KAAK,UAAU,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAuB,KAAK,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAI/E,MAAM,MAAM,QAAQ,GAAG;IACtB,UAAU,EAAE,UAAU,CAAC;IACvB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAErD,MAAM,MAAM,UAAU,GAAG;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,WAAW,EAAE,oBAAoB,CAAC;IAClC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AAE,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,CAAC,CAAC;IACvD;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAErD,MAAM,MAAM,UAAU,GAAG;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,WAAW,EAAE,oBAAoB,CAAC;IAClC,OAAO,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,UAAU,CAAC;CAC7C,CAAC;AAEF,oFAAoF;AACpF,wBAAgB,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,CAS/C;AAED,6DAA6D;AAC7D,wBAAgB,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAgBrF"}
@@ -22,6 +22,7 @@ function createPage(args, parent) {
22
22
  parent
23
23
  });
24
24
  return {
25
+ resourceType: "page",
25
26
  resourceId: args.resourceId,
26
27
  addDatabase: createChildDatabase({ type: "resourceId", resourceId: args.resourceId }),
27
28
  addPage(pageArgs) {
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=page.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page.test.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/page.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=workflow-access-types.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-access-types.test.d.ts","sourceRoot":"","sources":["../src/workflow-access-types.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,68 @@
1
+ import type { CustomAgentHandle } from "./notion-as-code/custom-agent.js";
2
+ import type { DataSourceHandle, DatabaseHandle, SingleSourceDatabaseHandle } from "./notion-as-code/database.js";
3
+ import type { PageHandle } from "./notion-as-code/page.js";
4
+ /** A Notion-as-Code resource that can provide a named workflow binding. */
5
+ export type WorkflowAccessResource = PageHandle | DatabaseHandle | SingleSourceDatabaseHandle | DataSourceHandle | CustomAgentHandle;
6
+ /** Resource kinds accepted by workflow access declarations. */
7
+ export type WorkflowAccessResourceType = WorkflowAccessResource["resourceType"];
8
+ /** Levels accepted by pages, databases, and data sources. */
9
+ export type WorkflowAccessResourceLevel = "view" | "comment" | "edit" | "fullAccess";
10
+ /** The only level accepted by a custom agent. */
11
+ export type WorkflowAccessAgentLevel = "call";
12
+ /** Every level accepted by at least one workflow access resource. */
13
+ export type WorkflowAccessLevel = WorkflowAccessResourceLevel | WorkflowAccessAgentLevel;
14
+ /** The level set accepted by a particular resource kind. */
15
+ export type WorkflowAccessLevelFor<TType extends WorkflowAccessResourceType> = TType extends "customAgent" ? WorkflowAccessAgentLevel : WorkflowAccessResourceLevel;
16
+ type AccessResourceFor<TType extends WorkflowAccessResourceType> = Extract<WorkflowAccessResource, {
17
+ resourceType: TType;
18
+ }>;
19
+ /** A named binding declaration pairing one NaC handle with its allowed level. */
20
+ export type WorkflowAccessDeclaration = {
21
+ [TType in WorkflowAccessResourceType]: {
22
+ readonly resource: AccessResourceFor<TType>;
23
+ readonly level: WorkflowAccessLevelFor<TType>;
24
+ };
25
+ }[WorkflowAccessResourceType];
26
+ /** Named binding declarations keyed by the names exposed on workflow context. */
27
+ export type WorkflowAccessDeclarations = Readonly<Record<string, WorkflowAccessDeclaration>>;
28
+ /** A normalized named-binding requirement, including the required NaC resourceId. */
29
+ export type WorkflowAccessRequirement = {
30
+ [TType in WorkflowAccessResourceType]: {
31
+ readonly type: TType;
32
+ readonly resourceId: string;
33
+ readonly level: WorkflowAccessLevelFor<TType>;
34
+ };
35
+ }[WorkflowAccessResourceType];
36
+ /** Normalized named-binding requirements keyed by public alias. */
37
+ export type WorkflowAccessRequirements = Readonly<Record<string, WorkflowAccessRequirement>>;
38
+ /** The resolved NaC binding exposed to a workflow handler. */
39
+ export type WorkflowAccessValue<TType extends WorkflowAccessResourceType = WorkflowAccessResourceType> = Readonly<{
40
+ type: TType;
41
+ id: string;
42
+ }>;
43
+ /** Resolved access values keyed by their public aliases. */
44
+ export type WorkflowAccess<TAccess extends WorkflowAccessDeclarations = WorkflowAccessDeclarations> = Readonly<{
45
+ [TKey in keyof TAccess]: TAccess[TKey] extends {
46
+ readonly resource: {
47
+ readonly resourceType: infer TType;
48
+ };
49
+ } ? TType extends WorkflowAccessResourceType ? WorkflowAccessValue<TType> : never : never;
50
+ }>;
51
+ /** Resolved NaC bindings keyed by public aliases, without declaration metadata. */
52
+ export type WorkflowAccessBindings = Readonly<Record<string, WorkflowAccessValue>>;
53
+ /**
54
+ * Normalize public binding declarations without retaining the handle objects.
55
+ * Handles contain methods and schema objects, so they must never be cloned into
56
+ * the manifest or captured by the runtime transport. These declarations do not
57
+ * grant or change the workflow's existing Notion-module permissions.
58
+ */
59
+ export declare function normalizeWorkflowAccess(declarations: WorkflowAccessDeclarations | undefined): WorkflowAccessRequirements;
60
+ /**
61
+ * Resolve trusted per-invocation NaC bindings into the minimal context value.
62
+ * This exposes only declared aliases and does not determine Notion API
63
+ * authorization; the workflow's existing Notion-module permissions do that.
64
+ * The environment is deliberately not parsed when no binding is required.
65
+ */
66
+ export declare function hydrateWorkflowAccess<TAccess extends WorkflowAccessDeclarations>(requirements: WorkflowAccessRequirements | undefined): WorkflowAccess<TAccess>;
67
+ export {};
68
+ //# sourceMappingURL=workflow-access.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-access.d.ts","sourceRoot":"","sources":["../src/workflow-access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EACX,gBAAgB,EAChB,cAAc,EACd,0BAA0B,EAC1B,MAAM,8BA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