@notionhq/apps 0.0.23 → 0.0.24
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.
- package/dist/notion-as-code/custom-agent.d.ts +43 -2
- package/dist/notion-as-code/custom-agent.d.ts.map +1 -1
- package/dist/notion-as-code/custom-agent.js +2 -2
- package/dist/notion-as-code/index.d.ts +1 -1
- package/dist/notion-as-code/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/notion-as-code/SKILL.md +3 -3
- package/src/notion-as-code/custom-agent.test.ts +17 -1
- package/src/notion-as-code/custom-agent.ts +48 -4
- package/src/notion-as-code/index.ts +3 -0
- package/src/notion-as-code/notion-as-code-types.test.ts +25 -0
|
@@ -72,6 +72,27 @@ export type CustomAgentPropertyUpdatedTrigger = CustomAgentTriggerBase & Propert
|
|
|
72
72
|
dataSourceResourceId: ResourceId;
|
|
73
73
|
};
|
|
74
74
|
export type CustomAgentTrigger = CustomAgentRecurrenceTrigger | CustomAgentPageAddedTrigger | CustomAgentPropertyUpdatedTrigger;
|
|
75
|
+
/**
|
|
76
|
+
* Defines access levels for resources that a custom agent can use.
|
|
77
|
+
*
|
|
78
|
+
* These values map to Notion module permissions: full access, content editing,
|
|
79
|
+
* commenting, and read-only.
|
|
80
|
+
*/
|
|
81
|
+
export type CustomAgentAccessRole = "full_access" | "can_edit_content" | "can_comment" | "can_view";
|
|
82
|
+
/** Grants a custom agent access to a page or database resource. */
|
|
83
|
+
export type CustomAgentAccess = {
|
|
84
|
+
resourceId: ResourceId;
|
|
85
|
+
role: CustomAgentAccessRole;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* URL trust settings for a custom agent.
|
|
89
|
+
*
|
|
90
|
+
* URL trust is independent from web access: an agent can trust URLs without
|
|
91
|
+
* being granted web search access.
|
|
92
|
+
*/
|
|
93
|
+
export type CustomAgentTrustedUrls = {
|
|
94
|
+
type: "all";
|
|
95
|
+
};
|
|
75
96
|
export type CustomAgentArgs = {
|
|
76
97
|
resourceId: ResourceId;
|
|
77
98
|
name: string;
|
|
@@ -80,14 +101,34 @@ export type CustomAgentArgs = {
|
|
|
80
101
|
}>;
|
|
81
102
|
instructions?: string;
|
|
82
103
|
model?: "ambrosia-tart-high" | "opal-quince-medium" | "almond-croissant-low";
|
|
83
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Whether the agent can use web search. Defaults to `false` when omitted for
|
|
106
|
+
* a new agent. When updating an existing agent, omitting this field preserves
|
|
107
|
+
* its current web access and domain restrictions.
|
|
108
|
+
*/
|
|
109
|
+
webAccess?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* URL trust policy for this agent. `{ type: "all" }` allows every HTTP and
|
|
112
|
+
* HTTPS URL. For a new agent, omitting this field leaves URL trust disabled;
|
|
113
|
+
* for an existing agent, omission preserves the current URL trust policy.
|
|
114
|
+
*/
|
|
115
|
+
trustedUrls?: CustomAgentTrustedUrls;
|
|
116
|
+
/**
|
|
117
|
+
* Grants the agent access to pages and databases.
|
|
118
|
+
*
|
|
119
|
+
* For an existing custom agent, omit this field or provide an empty list to
|
|
120
|
+
* preserve current page and database grants. Each listed resource adds a
|
|
121
|
+
* grant or replaces its existing grant with the listed role. Grants for
|
|
122
|
+
* unlisted resources remain unchanged.
|
|
123
|
+
*/
|
|
124
|
+
access?: readonly CustomAgentAccess[];
|
|
84
125
|
triggers?: readonly CustomAgentTrigger[];
|
|
85
126
|
};
|
|
86
127
|
export type CustomAgentHandle = {
|
|
87
128
|
readonly resourceType: "customAgent";
|
|
88
129
|
readonly resourceId: string;
|
|
89
130
|
};
|
|
90
|
-
/** Declare a custom agent and validate every
|
|
131
|
+
/** Declare a custom agent and validate every resource reference. */
|
|
91
132
|
export declare function customAgent(args: CustomAgentArgs): CustomAgentHandle;
|
|
92
133
|
export {};
|
|
93
134
|
//# sourceMappingURL=custom-agent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-agent.d.ts","sourceRo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CAAC,CAAC;IACnD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,oBAAoB,GAAG,oBAAoB,GAAG,sBAAsB,CAAC;IAC7E;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,WAAW,CAAC,EAAE,sBAAsB,CAAC;IACrC;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACtC,QAAQ,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC/B,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,oEAAoE;AACpE,wBAAgB,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,iBAAiB,CAoBpE"}
|
|
@@ -2,8 +2,8 @@ import { recordIntent } from "./recorder.js";
|
|
|
2
2
|
import { assertUserResourceId } from "./resource.js";
|
|
3
3
|
function customAgent(args) {
|
|
4
4
|
assertUserResourceId(args.resourceId);
|
|
5
|
-
for (const
|
|
6
|
-
assertUserResourceId(resourceId);
|
|
5
|
+
for (const grant of args.access ?? []) {
|
|
6
|
+
assertUserResourceId(grant.resourceId);
|
|
7
7
|
}
|
|
8
8
|
for (const trigger of args.triggers ?? []) {
|
|
9
9
|
assertUserResourceId(trigger.resourceId);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { APPS_RESERVED_RESOURCE_ID_PREFIX, APPS_WORKSPACE_RESOURCE_ID } from "./intents.js";
|
|
2
2
|
export type { ContentPageLayoutTab, DatabasePageLayout, DatabasePageLayoutTab, DatabaseIntent, DataSourceDefinition, NotionAsCodeIcon, NotionAsCodeProperty, NotionAsCodePropertyConfig, NotionAsCodeSchema, NotionAsCodeSelectOption, NotionAsCodeStatusOption, PageCoverReference, PageLayoutMainModule, PageLayoutNumberAndFormulaStyle, PageLayoutPersonStyle, PageLayoutPropertiesModule, PageLayoutPropertyConfig, PageLayoutPropertyModule, PageLayoutPropertySection, PageLayoutRelationConfig, PageLayoutRelationsGroupModule, PageLayoutSidebarModule, Parent, ResourceId, RollupBaseAggregationType, RollupDateAggregationType, RollupNumberAggregationType, RollupTargetPropertyType, ViewPageLayoutTab, } from "./intents.js";
|
|
3
|
-
export type { CustomAgentArgs, CustomAgentHandle, CustomAgentPageAddedTrigger, CustomAgentPropertyUpdatedTrigger, CustomAgentRecurrenceSchedule, CustomAgentRecurrenceTrigger, CustomAgentTrigger, CustomAgentTriggerBase, DailyRecurrenceSchedule, HourlyRecurrenceSchedule, MonthlyRecurrenceRestriction, MonthlyRecurrenceSchedule, MonthlyWeekdayOccurrence, PropertyTriggerCondition, RecurrenceScheduleEnd, RecurrenceWeekdays, WeeklyRecurrenceSchedule, YearlyRecurrenceSchedule, } from "./custom-agent.js";
|
|
3
|
+
export type { CustomAgentAccess, CustomAgentAccessRole, CustomAgentArgs, CustomAgentHandle, CustomAgentPageAddedTrigger, CustomAgentPropertyUpdatedTrigger, CustomAgentRecurrenceSchedule, CustomAgentRecurrenceTrigger, CustomAgentTrustedUrls, CustomAgentTrigger, CustomAgentTriggerBase, DailyRecurrenceSchedule, HourlyRecurrenceSchedule, MonthlyRecurrenceRestriction, MonthlyRecurrenceSchedule, MonthlyWeekdayOccurrence, PropertyTriggerCondition, RecurrenceScheduleEnd, RecurrenceWeekdays, WeeklyRecurrenceSchedule, YearlyRecurrenceSchedule, } from "./custom-agent.js";
|
|
4
4
|
export type { ChildDatabaseArgs, ChildDatabaseFactory, ChildMultiSourceDatabaseArgs, ChildSingleSourceDatabaseArgs, DataSourceArgs, DataSourceHandle, DataSourceMap, DatabaseArgs, DatabaseHandle, MultiSourceDatabaseArgs, SingleSourceDatabaseArgs, SingleSourceDatabaseHandle, } from "./database.js";
|
|
5
5
|
export { toCustomBlockDefaultBinding, toCustomBlockDataSource } from "../translate.js";
|
|
6
6
|
export type { ChildPageArgs, PageArgs, PageHandle, PropertyValue, SimpleTextToken, TextValue, VerificationInput, VerificationPropertyValue, } from "./page.js";
|
|
@@ -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,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,0BAA0B,EAC1B,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,oBAAoB,EACpB,+BAA+B,EAC/B,qBAAqB,EACrB,0BAA0B,EAC1B,wBAAwB,EACxB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,8BAA8B,EAC9B,uBAAuB,EACvB,MAAM,EACN,UAAU,EACV,yBAAyB,EACzB,yBAAyB,EACzB,2BAA2B,EAC3B,wBAAwB,EACxB,iBAAiB,GACjB,MAAM,cAAc,CAAC;AACtB,YAAY,EACX,eAAe,EACf,iBAAiB,EACjB,2BAA2B,EAC3B,iCAAiC,EACjC,6BAA6B,EAC7B,4BAA4B,EAC5B,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,4BAA4B,EAC5B,yBAAyB,EACzB,wBAAwB,EACxB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,GACxB,MAAM,mBAAmB,CAAC;AAC3B,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,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AACvF,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
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gCAAgC,EAAE,0B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AAE,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"}
|
package/package.json
CHANGED
|
@@ -86,9 +86,9 @@ root exports support:
|
|
|
86
86
|
`database(resourceId, { datasources: { Key: { resourceId, schema } }, views?, parent? })`,
|
|
87
87
|
returning sources as `handle.datasources.Key`. A source's `addPage` declares a row;
|
|
88
88
|
the database handle also exposes `addView`.
|
|
89
|
-
- `customAgent({ resourceId, name, instructions?,
|
|
90
|
-
|
|
91
|
-
before specifying models or
|
|
89
|
+
- `customAgent({ resourceId, name, instructions?, access?, webAccess?, trustedUrls? })`.
|
|
90
|
+
Access grants pair declared page or database resource IDs with a role. Inspect
|
|
91
|
+
the installed types before specifying models, triggers, or URL trust.
|
|
92
92
|
- `view({ databaseResourceId, resourceId, type, dataSourceResourceId, ... })`,
|
|
93
93
|
returning a handle with `resourceId`. This is also available as `notion.view`.
|
|
94
94
|
Use property resource IDs in view filters, sorts, and layout options; calendar
|
|
@@ -4,12 +4,15 @@ import { notion } from "./index.js";
|
|
|
4
4
|
import { finishMetadataRecording, startMetadataRecording } from "./recorder.js";
|
|
5
5
|
|
|
6
6
|
describe("Notion-as-Code custom agent declarations", () => {
|
|
7
|
-
it("records
|
|
7
|
+
it("records access, web, URL trust, and triggers", () => {
|
|
8
8
|
const recorder = startMetadataRecording();
|
|
9
9
|
|
|
10
10
|
notion.customAgent({
|
|
11
11
|
resourceId: "triage-agent",
|
|
12
12
|
name: "Triage agent",
|
|
13
|
+
webAccess: true,
|
|
14
|
+
trustedUrls: { type: "all" },
|
|
15
|
+
access: [{ resourceId: "tasks", role: "can_edit_content" }],
|
|
13
16
|
triggers: [
|
|
14
17
|
{
|
|
15
18
|
type: "recurrence",
|
|
@@ -37,6 +40,9 @@ describe("Notion-as-Code custom agent declarations", () => {
|
|
|
37
40
|
type: "custom_agent",
|
|
38
41
|
resourceId: "triage-agent",
|
|
39
42
|
name: "Triage agent",
|
|
43
|
+
webAccess: true,
|
|
44
|
+
trustedUrls: { type: "all" },
|
|
45
|
+
access: [{ resourceId: "tasks", role: "can_edit_content" }],
|
|
40
46
|
triggers: [
|
|
41
47
|
{
|
|
42
48
|
type: "recurrence",
|
|
@@ -76,4 +82,14 @@ describe("Notion-as-Code custom agent declarations", () => {
|
|
|
76
82
|
}),
|
|
77
83
|
).toThrow("reserved");
|
|
78
84
|
});
|
|
85
|
+
|
|
86
|
+
it("rejects reserved resource IDs inside access grants", () => {
|
|
87
|
+
expect(() =>
|
|
88
|
+
notion.customAgent({
|
|
89
|
+
resourceId: "triage-agent",
|
|
90
|
+
name: "Triage agent",
|
|
91
|
+
access: [{ resourceId: "__notion_apps_tasks", role: "can_view" }],
|
|
92
|
+
}),
|
|
93
|
+
).toThrow("reserved");
|
|
94
|
+
});
|
|
79
95
|
});
|
|
@@ -101,13 +101,57 @@ export type CustomAgentTrigger =
|
|
|
101
101
|
| CustomAgentPageAddedTrigger
|
|
102
102
|
| CustomAgentPropertyUpdatedTrigger;
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Defines access levels for resources that a custom agent can use.
|
|
106
|
+
*
|
|
107
|
+
* These values map to Notion module permissions: full access, content editing,
|
|
108
|
+
* commenting, and read-only.
|
|
109
|
+
*/
|
|
110
|
+
export type CustomAgentAccessRole = "full_access" | "can_edit_content" | "can_comment" | "can_view";
|
|
111
|
+
|
|
112
|
+
/** Grants a custom agent access to a page or database resource. */
|
|
113
|
+
export type CustomAgentAccess = {
|
|
114
|
+
resourceId: ResourceId;
|
|
115
|
+
role: CustomAgentAccessRole;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* URL trust settings for a custom agent.
|
|
120
|
+
*
|
|
121
|
+
* URL trust is independent from web access: an agent can trust URLs without
|
|
122
|
+
* being granted web search access.
|
|
123
|
+
*/
|
|
124
|
+
export type CustomAgentTrustedUrls = {
|
|
125
|
+
type: "all";
|
|
126
|
+
};
|
|
127
|
+
|
|
104
128
|
export type CustomAgentArgs = {
|
|
105
129
|
resourceId: ResourceId;
|
|
106
130
|
name: string;
|
|
107
131
|
icon?: Exclude<NotionAsCodeIcon, { type: "file" }>;
|
|
108
132
|
instructions?: string;
|
|
109
133
|
model?: "ambrosia-tart-high" | "opal-quince-medium" | "almond-croissant-low";
|
|
110
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Whether the agent can use web search. Defaults to `false` when omitted for
|
|
136
|
+
* a new agent. When updating an existing agent, omitting this field preserves
|
|
137
|
+
* its current web access and domain restrictions.
|
|
138
|
+
*/
|
|
139
|
+
webAccess?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* URL trust policy for this agent. `{ type: "all" }` allows every HTTP and
|
|
142
|
+
* HTTPS URL. For a new agent, omitting this field leaves URL trust disabled;
|
|
143
|
+
* for an existing agent, omission preserves the current URL trust policy.
|
|
144
|
+
*/
|
|
145
|
+
trustedUrls?: CustomAgentTrustedUrls;
|
|
146
|
+
/**
|
|
147
|
+
* Grants the agent access to pages and databases.
|
|
148
|
+
*
|
|
149
|
+
* For an existing custom agent, omit this field or provide an empty list to
|
|
150
|
+
* preserve current page and database grants. Each listed resource adds a
|
|
151
|
+
* grant or replaces its existing grant with the listed role. Grants for
|
|
152
|
+
* unlisted resources remain unchanged.
|
|
153
|
+
*/
|
|
154
|
+
access?: readonly CustomAgentAccess[];
|
|
111
155
|
triggers?: readonly CustomAgentTrigger[];
|
|
112
156
|
};
|
|
113
157
|
|
|
@@ -116,11 +160,11 @@ export type CustomAgentHandle = {
|
|
|
116
160
|
readonly resourceId: string;
|
|
117
161
|
};
|
|
118
162
|
|
|
119
|
-
/** Declare a custom agent and validate every
|
|
163
|
+
/** Declare a custom agent and validate every resource reference. */
|
|
120
164
|
export function customAgent(args: CustomAgentArgs): CustomAgentHandle {
|
|
121
165
|
assertUserResourceId(args.resourceId);
|
|
122
|
-
for (const
|
|
123
|
-
assertUserResourceId(resourceId);
|
|
166
|
+
for (const grant of args.access ?? []) {
|
|
167
|
+
assertUserResourceId(grant.resourceId);
|
|
124
168
|
}
|
|
125
169
|
for (const trigger of args.triggers ?? []) {
|
|
126
170
|
assertUserResourceId(trigger.resourceId);
|
|
@@ -33,12 +33,15 @@ export type {
|
|
|
33
33
|
ViewPageLayoutTab,
|
|
34
34
|
} from "./intents.js";
|
|
35
35
|
export type {
|
|
36
|
+
CustomAgentAccess,
|
|
37
|
+
CustomAgentAccessRole,
|
|
36
38
|
CustomAgentArgs,
|
|
37
39
|
CustomAgentHandle,
|
|
38
40
|
CustomAgentPageAddedTrigger,
|
|
39
41
|
CustomAgentPropertyUpdatedTrigger,
|
|
40
42
|
CustomAgentRecurrenceSchedule,
|
|
41
43
|
CustomAgentRecurrenceTrigger,
|
|
44
|
+
CustomAgentTrustedUrls,
|
|
42
45
|
CustomAgentTrigger,
|
|
43
46
|
CustomAgentTriggerBase,
|
|
44
47
|
DailyRecurrenceSchedule,
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { expectTypeOf, it } from "vitest";
|
|
2
2
|
|
|
3
3
|
import type {
|
|
4
|
+
CustomAgentAccess,
|
|
5
|
+
CustomAgentAccessRole,
|
|
4
6
|
CustomAgentArgs,
|
|
5
7
|
CustomAgentPropertyUpdatedTrigger,
|
|
8
|
+
CustomAgentTrustedUrls,
|
|
6
9
|
CustomAgentTrigger,
|
|
7
10
|
DatabasePageLayout,
|
|
8
11
|
NotionAsCodePropertyConfig,
|
|
@@ -12,6 +15,28 @@ import type {
|
|
|
12
15
|
SingleSourceDatabaseArgs,
|
|
13
16
|
} from "./index.js";
|
|
14
17
|
|
|
18
|
+
it("types custom agent resource access and URL trust", () => {
|
|
19
|
+
expectTypeOf<
|
|
20
|
+
"full_access" | "can_edit_content" | "can_comment" | "can_view"
|
|
21
|
+
>().toEqualTypeOf<CustomAgentAccessRole>();
|
|
22
|
+
expectTypeOf<{
|
|
23
|
+
resourceId: "tasks";
|
|
24
|
+
role: "can_view";
|
|
25
|
+
}>().toExtend<CustomAgentAccess>();
|
|
26
|
+
expectTypeOf<{
|
|
27
|
+
resourceId: "tasks";
|
|
28
|
+
role: "read_and_write";
|
|
29
|
+
}>().not.toExtend<CustomAgentAccess>();
|
|
30
|
+
expectTypeOf<{ type: "all" }>().toEqualTypeOf<CustomAgentTrustedUrls>();
|
|
31
|
+
expectTypeOf<CustomAgentArgs["webAccess"]>().toEqualTypeOf<boolean | undefined>();
|
|
32
|
+
expectTypeOf<CustomAgentArgs["trustedUrls"]>().toEqualTypeOf<
|
|
33
|
+
CustomAgentTrustedUrls | undefined
|
|
34
|
+
>();
|
|
35
|
+
expectTypeOf<CustomAgentArgs["access"]>().toEqualTypeOf<
|
|
36
|
+
readonly CustomAgentAccess[] | undefined
|
|
37
|
+
>();
|
|
38
|
+
});
|
|
39
|
+
|
|
15
40
|
it("types page and database covers as URL references", () => {
|
|
16
41
|
expectTypeOf<{
|
|
17
42
|
type: "url";
|