@notionhq/apps 0.0.21 → 0.0.23

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 (46) hide show
  1. package/README.md +2 -1
  2. package/dist/cli/build.d.ts.map +1 -1
  3. package/dist/cli/build.js +1 -4
  4. package/dist/custom-block.d.ts +14 -2
  5. package/dist/custom-block.d.ts.map +1 -1
  6. package/dist/custom-block.js +27 -2
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +2 -0
  10. package/dist/notion-as-code/database.d.ts +3 -0
  11. package/dist/notion-as-code/database.d.ts.map +1 -1
  12. package/dist/notion-as-code/database.js +6 -2
  13. package/dist/notion-as-code/index.d.ts +1 -0
  14. package/dist/notion-as-code/index.d.ts.map +1 -1
  15. package/dist/notion-as-code/index.js +4 -1
  16. package/dist/notion-as-code/intents.d.ts +1 -0
  17. package/dist/notion-as-code/intents.d.ts.map +1 -1
  18. package/dist/translate.d.ts +10 -0
  19. package/dist/translate.d.ts.map +1 -0
  20. package/dist/translate.js +65 -0
  21. package/dist/workflow-access.d.ts +29 -0
  22. package/dist/workflow-access.d.ts.map +1 -1
  23. package/dist/workflow-access.js +23 -0
  24. package/dist/workflow.d.ts +1 -0
  25. package/dist/workflow.d.ts.map +1 -1
  26. package/dist/workflow.js +2 -0
  27. package/docs/BUILD.md +5 -3
  28. package/package.json +1 -1
  29. package/skills/custom-blocks/SKILL.md +4 -4
  30. package/skills/notion-as-code/SKILL.md +8 -5
  31. package/skills/workflow/SKILL.md +5 -5
  32. package/src/cli/build.test.ts +55 -0
  33. package/src/cli/build.ts +1 -4
  34. package/src/cli/codegen.test.ts +17 -1
  35. package/src/custom-block.test.ts +138 -2
  36. package/src/custom-block.ts +49 -2
  37. package/src/index.ts +1 -0
  38. package/src/notion-as-code/database.test.ts +5 -1
  39. package/src/notion-as-code/database.ts +9 -1
  40. package/src/notion-as-code/index.ts +1 -0
  41. package/src/notion-as-code/intents.ts +1 -0
  42. package/src/translate.ts +77 -0
  43. package/src/workflow-access-types.test.ts +8 -4
  44. package/src/workflow-access.ts +41 -0
  45. package/src/workflow.test.ts +5 -4
  46. package/src/workflow.ts +1 -0
@@ -14,6 +14,8 @@ export type WorkflowAccessResource =
14
14
  | DataSourceHandle
15
15
  | CustomAgentHandle;
16
16
 
17
+ type WorkflowAccessContentResource = Exclude<WorkflowAccessResource, CustomAgentHandle>;
18
+
17
19
  /** Resource kinds accepted by workflow access declarations. */
18
20
  export type WorkflowAccessResourceType = WorkflowAccessResource["resourceType"];
19
21
 
@@ -82,6 +84,45 @@ export type WorkflowAccess<
82
84
  /** Resolved NaC bindings keyed by public aliases, without declaration metadata. */
83
85
  export type WorkflowAccessBindings = Readonly<Record<string, WorkflowAccessValue>>;
84
86
 
87
+ /** Create type-safe access declarations for Notion-as-Code resource handles. */
88
+ export const access = {
89
+ view,
90
+ comment,
91
+ edit,
92
+ fullAccess,
93
+ call,
94
+ };
95
+
96
+ function view<TResource extends WorkflowAccessContentResource>(
97
+ resource: TResource,
98
+ ): Readonly<{ resource: TResource; level: "view" }> {
99
+ return { resource, level: "view" };
100
+ }
101
+
102
+ function comment<TResource extends WorkflowAccessContentResource>(
103
+ resource: TResource,
104
+ ): Readonly<{ resource: TResource; level: "comment" }> {
105
+ return { resource, level: "comment" };
106
+ }
107
+
108
+ function edit<TResource extends WorkflowAccessContentResource>(
109
+ resource: TResource,
110
+ ): Readonly<{ resource: TResource; level: "edit" }> {
111
+ return { resource, level: "edit" };
112
+ }
113
+
114
+ function fullAccess<TResource extends WorkflowAccessContentResource>(
115
+ resource: TResource,
116
+ ): Readonly<{ resource: TResource; level: "fullAccess" }> {
117
+ return { resource, level: "fullAccess" };
118
+ }
119
+
120
+ function call(
121
+ resource: CustomAgentHandle,
122
+ ): Readonly<{ resource: CustomAgentHandle; level: "call" }> {
123
+ return { resource, level: "call" };
124
+ }
125
+
85
126
  const ACCESS_ALIAS_PATTERN = /^[a-zA-Z][a-zA-Z0-9_-]{0,127}$/;
86
127
  const RESERVED_ACCESS_ALIASES = new Set<string>(["__proto__", "prototype", "constructor"]);
87
128
  const RESOURCE_TYPES: Record<WorkflowAccessResourceType, true> = {
@@ -12,6 +12,7 @@ import { customAgent } from "./notion-as-code/custom-agent.js";
12
12
  import { database } from "./notion-as-code/database.js";
13
13
  import { page } from "./notion-as-code/page.js";
14
14
  import {
15
+ access,
15
16
  connections,
16
17
  workflow,
17
18
  type StepContext,
@@ -1216,10 +1217,10 @@ describe("workflow", () => {
1216
1217
  description: "Hydrates access",
1217
1218
  triggers: [triggers.notionPageCreated()],
1218
1219
  access: {
1219
- home: { resource: home, level: "view" },
1220
- table: { resource: table, level: "edit" },
1221
- source: { resource: table.dataSource, level: "comment" },
1222
- agent: { resource: agent, level: "call" },
1220
+ home: access.view(home),
1221
+ table: access.edit(table),
1222
+ source: access.comment(table.dataSource),
1223
+ agent: access.call(agent),
1223
1224
  },
1224
1225
  handler: (_event, context) => {
1225
1226
  expectTypeOf(context.access.home.type).toEqualTypeOf<"page">();
package/src/workflow.ts CHANGED
@@ -91,6 +91,7 @@ export type {
91
91
  WorkflowAccessRequirements,
92
92
  WorkflowAccessValue,
93
93
  } from "./workflow-access.js";
94
+ export { access } from "./workflow-access.js";
94
95
  export type WorkflowEvent = WorkflowEventMap[keyof WorkflowEventMap];
95
96
 
96
97
  export type WorkflowEventForTrigger<T extends WorkflowTrigger> = WorkflowEventMap[T["type"]];