@sanity/agent-directives 0.0.15 → 0.0.17
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/_chunks-dts/index.d.ts +43 -1
- package/dist/_chunks-dts/index.d.ts.map +1 -1
- package/dist/_chunks-es/formatters.js +16 -2
- package/dist/_chunks-es/formatters.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -1
- package/dist/lib/formatters.d.ts +2 -2
- package/dist/lib/formatters.js +2 -1
- package/dist/lib/react.d.ts +1 -1
- package/dist/lib/server.d.ts +1 -1
- package/package.json +2 -2
|
@@ -53,6 +53,25 @@ declare const ChangesDirectiveSchema: z.ZodObject<{
|
|
|
53
53
|
createdCount: number;
|
|
54
54
|
updatedCount: number;
|
|
55
55
|
}>;
|
|
56
|
+
declare const ConfirmDirectiveSchema: z.ZodObject<{
|
|
57
|
+
status: z.ZodEnum<["pending", "approved", "cancelled"]>;
|
|
58
|
+
toolCallId: z.ZodString;
|
|
59
|
+
runId: z.ZodString;
|
|
60
|
+
toolName: z.ZodString;
|
|
61
|
+
data: z.ZodString;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
status: "pending" | "approved" | "cancelled";
|
|
64
|
+
toolCallId: string;
|
|
65
|
+
runId: string;
|
|
66
|
+
toolName: string;
|
|
67
|
+
data: string;
|
|
68
|
+
}, {
|
|
69
|
+
status: "pending" | "approved" | "cancelled";
|
|
70
|
+
toolCallId: string;
|
|
71
|
+
runId: string;
|
|
72
|
+
toolName: string;
|
|
73
|
+
data: string;
|
|
74
|
+
}>;
|
|
56
75
|
declare const DirectiveSchemas: {
|
|
57
76
|
readonly document: z.ZodObject<{
|
|
58
77
|
id: z.ZodString;
|
|
@@ -108,6 +127,25 @@ declare const DirectiveSchemas: {
|
|
|
108
127
|
}, {
|
|
109
128
|
source: string;
|
|
110
129
|
}>;
|
|
130
|
+
readonly confirm: z.ZodObject<{
|
|
131
|
+
status: z.ZodEnum<["pending", "approved", "cancelled"]>;
|
|
132
|
+
toolCallId: z.ZodString;
|
|
133
|
+
runId: z.ZodString;
|
|
134
|
+
toolName: z.ZodString;
|
|
135
|
+
data: z.ZodString;
|
|
136
|
+
}, "strip", z.ZodTypeAny, {
|
|
137
|
+
status: "pending" | "approved" | "cancelled";
|
|
138
|
+
toolCallId: string;
|
|
139
|
+
runId: string;
|
|
140
|
+
toolName: string;
|
|
141
|
+
data: string;
|
|
142
|
+
}, {
|
|
143
|
+
status: "pending" | "approved" | "cancelled";
|
|
144
|
+
toolCallId: string;
|
|
145
|
+
runId: string;
|
|
146
|
+
toolName: string;
|
|
147
|
+
data: string;
|
|
148
|
+
}>;
|
|
111
149
|
};
|
|
112
150
|
declare const DIRECTIVE_NAMES: {
|
|
113
151
|
readonly document: "document";
|
|
@@ -116,6 +154,7 @@ declare const DIRECTIVE_NAMES: {
|
|
|
116
154
|
readonly set: "set";
|
|
117
155
|
readonly changes: "changes";
|
|
118
156
|
readonly requestProjectAccess: "requestProjectAccess";
|
|
157
|
+
readonly confirm: "confirm";
|
|
119
158
|
};
|
|
120
159
|
type DirectiveName = (typeof DIRECTIVE_NAMES)[keyof typeof DIRECTIVE_NAMES];
|
|
121
160
|
type DocumentDirectiveProps = z.infer<typeof DocumentDirectiveSchema>;
|
|
@@ -124,6 +163,7 @@ type ResourceDirectiveProps = z.infer<typeof ResourceDirectiveSchema>;
|
|
|
124
163
|
type SetDirectiveProps = z.infer<typeof SetDirectiveSchema>;
|
|
125
164
|
type ChangesDirectiveProps = z.infer<typeof ChangesDirectiveSchema>;
|
|
126
165
|
type RequestProjectAccessDirectiveProps = z.infer<typeof RequestProjectAccessDirectiveSchema>;
|
|
166
|
+
type ConfirmDirectiveProps = z.infer<typeof ConfirmDirectiveSchema>;
|
|
127
167
|
interface DirectivePropsMap {
|
|
128
168
|
document: DocumentDirectiveProps;
|
|
129
169
|
release: ReleaseDirectiveProps;
|
|
@@ -131,6 +171,7 @@ interface DirectivePropsMap {
|
|
|
131
171
|
set: SetDirectiveProps;
|
|
132
172
|
changes: ChangesDirectiveProps;
|
|
133
173
|
requestProjectAccess: RequestProjectAccessDirectiveProps;
|
|
174
|
+
confirm: ConfirmDirectiveProps;
|
|
134
175
|
}
|
|
135
176
|
interface DefineDirectiveOptions {
|
|
136
177
|
/**
|
|
@@ -148,5 +189,6 @@ declare function createResourceDirective(props: ResourceDirectiveProps): string;
|
|
|
148
189
|
declare function createSetDirective(props: SetDirectiveProps): string;
|
|
149
190
|
declare function createChangesDirective(props: ChangesDirectiveProps): string;
|
|
150
191
|
declare function createRequestProjectAccessDirective(props: RequestProjectAccessDirectiveProps): string;
|
|
151
|
-
|
|
192
|
+
declare function createConfirmDirective(props: ConfirmDirectiveProps, label?: string): string;
|
|
193
|
+
export { createRequestProjectAccessDirective as C, formatDirective as E, createReleaseDirective as S, createSetDirective as T, SetDirectiveProps as _, DIRECTIVE_NAMES as a, createConfirmDirective as b, DirectivePropsMap as c, DocumentDirectiveSchema as d, ReleaseDirectiveProps as f, ResourceDirectiveSchema as g, ResourceDirectiveProps as h, ConfirmDirectiveSchema as i, DirectiveSchemas as l, RequestProjectAccessDirectiveProps as m, ChangesDirectiveSchema as n, DefineDirectiveOptions as o, ReleaseDirectiveSchema as p, ConfirmDirectiveProps as r, DirectiveName as s, ChangesDirectiveProps as t, DocumentDirectiveProps as u, SetDirectiveSchema as v, createResourceDirective as w, createDocumentDirective as x, createChangesDirective as y };
|
|
152
194
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/_internal/index.ts"],"mappings":";cAKa,uBAAA,EAAuB,CAAA,CAAA,SAAA;;;;;;;;;;;;;cAMvB,sBAAA,EAAsB,CAAA,CAAA,SAAA;;;;;;;;;;cAKtB,uBAAA,EAAuB,CAAA,CAAA,SAAA;;;;;;;cAIvB,mCAAA,EAAmC,CAAA,CAAA,SAAA;;;;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AAA;EACL,OAAA,EAAS,qBAAA;EACT,oBAAA,EAAsB,kCAAA;EACtB,OAAA,EAAS,qBAAA;AAAA;AAAA,UAGM,sBAAA;;;;;EAKf,eAAA;;EAEA,mBAAA;AAAA;AAAA,iBA8Bc,eAAA,CACd,IAAA,EAAM,aAAA,EACN,KAAA,EAAO,MAAA,mBACP,KAAA;AAAA,iBASc,uBAAA,CAAwB,KAAA,EAAO,sBAAA,EAAwB,KAAA;AAAA,iBAIvD,sBAAA,CAAuB,KAAA,EAAO,qBAAA,EAAuB,KAAA;AAAA,iBAIrD,uBAAA,CAAwB,KAAA,EAAO,sBAAA;AAAA,iBAI/B,kBAAA,CAAmB,KAAA,EAAO,iBAAA;AAAA,iBAI1B,sBAAA,CAAuB,KAAA,EAAO,qBAAA;AAAA,iBAI9B,mCAAA,CACd,KAAA,EAAO,kCAAA;AAAA,iBAKO,sBAAA,CAAuB,KAAA,EAAO,qBAAA,EAAuB,KAAA"}
|
|
@@ -15,20 +15,29 @@ const DocumentDirectiveSchema = z.object({
|
|
|
15
15
|
}), ChangesDirectiveSchema = z.object({
|
|
16
16
|
createdCount: z.coerce.number().min(0),
|
|
17
17
|
updatedCount: z.coerce.number().min(0)
|
|
18
|
+
}), ConfirmDirectiveSchema = z.object({
|
|
19
|
+
status: z.enum(["pending", "approved", "cancelled"]),
|
|
20
|
+
toolCallId: z.string(),
|
|
21
|
+
runId: z.string(),
|
|
22
|
+
toolName: z.string(),
|
|
23
|
+
data: z.string()
|
|
24
|
+
// base64-encoded JSON, typed per toolName
|
|
18
25
|
}), DirectiveSchemas = {
|
|
19
26
|
document: DocumentDirectiveSchema,
|
|
20
27
|
release: ReleaseDirectiveSchema,
|
|
21
28
|
resource: ResourceDirectiveSchema,
|
|
22
29
|
set: SetDirectiveSchema,
|
|
23
30
|
changes: ChangesDirectiveSchema,
|
|
24
|
-
requestProjectAccess: RequestProjectAccessDirectiveSchema
|
|
31
|
+
requestProjectAccess: RequestProjectAccessDirectiveSchema,
|
|
32
|
+
confirm: ConfirmDirectiveSchema
|
|
25
33
|
}, DIRECTIVE_NAMES = {
|
|
26
34
|
document: "document",
|
|
27
35
|
release: "release",
|
|
28
36
|
resource: "resource",
|
|
29
37
|
set: "set",
|
|
30
38
|
changes: "changes",
|
|
31
|
-
requestProjectAccess: "requestProjectAccess"
|
|
39
|
+
requestProjectAccess: "requestProjectAccess",
|
|
40
|
+
confirm: "confirm"
|
|
32
41
|
}, DIRECTIVE_TYPES = ["textDirective", "leafDirective", "containerDirective"], LABEL = "(?:[^\\[\\]]|\\[[^\\[\\]]*\\])*", BLOCK_DIRECTIVE = new RegExp(`::([a-zA-Z]\\w*)(?:\\[(${LABEL})\\])?\\{([^}]*)\\}`), INLINE_DIRECTIVE = new RegExp(`:([a-zA-Z]\\w*)\\[(${LABEL})\\]\\{([^}]*)\\}`);
|
|
33
42
|
function parseDirectiveAttributes(attrString) {
|
|
34
43
|
const attrs = {};
|
|
@@ -61,9 +70,13 @@ function createChangesDirective(props) {
|
|
|
61
70
|
function createRequestProjectAccessDirective(props) {
|
|
62
71
|
return formatDirective(DIRECTIVE_NAMES.requestProjectAccess, props);
|
|
63
72
|
}
|
|
73
|
+
function createConfirmDirective(props, label) {
|
|
74
|
+
return formatDirective(DIRECTIVE_NAMES.confirm, props, label);
|
|
75
|
+
}
|
|
64
76
|
export {
|
|
65
77
|
BLOCK_DIRECTIVE,
|
|
66
78
|
ChangesDirectiveSchema,
|
|
79
|
+
ConfirmDirectiveSchema,
|
|
67
80
|
DIRECTIVE_NAMES,
|
|
68
81
|
DIRECTIVE_TYPES,
|
|
69
82
|
DirectiveSchemas,
|
|
@@ -73,6 +86,7 @@ export {
|
|
|
73
86
|
ResourceDirectiveSchema,
|
|
74
87
|
SetDirectiveSchema,
|
|
75
88
|
createChangesDirective,
|
|
89
|
+
createConfirmDirective,
|
|
76
90
|
createDocumentDirective,
|
|
77
91
|
createReleaseDirective,
|
|
78
92
|
createRequestProjectAccessDirective,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.js","sources":["../../src/_internal/index.ts"],"sourcesContent":["// This internal module contains all shared code that both the main index\n// and sub-exports can import without causing self-referencing issues with pkg-utils\n\nimport { z } from 'zod'\n\nexport const DocumentDirectiveSchema = z.object({\n id: z.string(),\n type: z.string().optional(),\n source: z.string().optional(),\n})\n\nexport const ReleaseDirectiveSchema = z.object({\n id: z.string(),\n source: z.string().optional(),\n})\n\nexport const ResourceDirectiveSchema = z.object({\n source: z.string(),\n})\n\nexport const RequestProjectAccessDirectiveSchema = z.object({\n source: z.string(),\n})\n\nexport const SetDirectiveSchema = z.object({\n id: z.string(),\n})\n\nexport const ChangesDirectiveSchema = z.object({\n createdCount: z.coerce.number().min(0),\n updatedCount: z.coerce.number().min(0),\n})\n\nexport const DirectiveSchemas = {\n document: DocumentDirectiveSchema,\n release: ReleaseDirectiveSchema,\n resource: ResourceDirectiveSchema,\n set: SetDirectiveSchema,\n changes: ChangesDirectiveSchema,\n requestProjectAccess: RequestProjectAccessDirectiveSchema,\n} as const\n\nexport const DIRECTIVE_NAMES = {\n document: 'document',\n release: 'release',\n resource: 'resource',\n set: 'set',\n changes: 'changes',\n requestProjectAccess: 'requestProjectAccess',\n} as const\n\nexport const DIRECTIVE_TYPES = ['textDirective', 'leafDirective', 'containerDirective'] as const\n\nexport type DirectiveType = (typeof DIRECTIVE_TYPES)[number]\n\nexport type DirectiveName = (typeof DIRECTIVE_NAMES)[keyof typeof DIRECTIVE_NAMES]\n\nexport type DocumentDirectiveProps = z.infer<typeof DocumentDirectiveSchema>\nexport type ReleaseDirectiveProps = z.infer<typeof ReleaseDirectiveSchema>\nexport type ResourceDirectiveProps = z.infer<typeof ResourceDirectiveSchema>\nexport type SetDirectiveProps = z.infer<typeof SetDirectiveSchema>\nexport type ChangesDirectiveProps = z.infer<typeof ChangesDirectiveSchema>\nexport type RequestProjectAccessDirectiveProps = z.infer<typeof RequestProjectAccessDirectiveSchema>\n\nexport interface DirectivePropsMap {\n document: DocumentDirectiveProps\n release: ReleaseDirectiveProps\n resource: ResourceDirectiveProps\n set: SetDirectiveProps\n changes: ChangesDirectiveProps\n requestProjectAccess: RequestProjectAccessDirectiveProps\n}\n\nexport interface DefineDirectiveOptions {\n /**\n * Whether this directive requires context/application to render.\n * If true (default), the directive won't render without context.\n */\n requiresContext?: boolean\n /** @deprecated Use `requiresContext` instead */\n requiresApplication?: boolean\n}\n\n// Label content pattern: matches non-bracket chars or single-level nested [...]\n// e.g. \"Guide [E-commerce edition]\" matches, but won't span across \"] other text [\"\nconst LABEL = '(?:[^\\\\[\\\\]]|\\\\[[^\\\\[\\\\]]*\\\\])*'\n\n// Matches block directives: ::name{attrs} or ::name[label]{attrs}\n// Captures: (1) name, (2) label or undefined, (3) attribute string\nexport const BLOCK_DIRECTIVE = new RegExp(`::([a-zA-Z]\\\\w*)(?:\\\\[(${LABEL})\\\\])?\\\\{([^}]*)\\\\}`)\n\n// Matches inline directives: :name[label]{attrs}\n// Captures: (1) name, (2) label, (3) attribute string\nexport const INLINE_DIRECTIVE = new RegExp(`:([a-zA-Z]\\\\w*)\\\\[(${LABEL})\\\\]\\\\{([^}]*)\\\\}`)\n\nexport function parseDirectiveAttributes(attrString: string): Record<string, string> {\n const attrs: Record<string, string> = {}\n for (const match of attrString.matchAll(/(\\w+)=\"([^\"]*)\"/g)) {\n attrs[match[1]] = match[2]\n }\n return attrs\n}\n\nfunction buildAttributes(params: Record<string, unknown>): string {\n return Object.entries(params)\n .filter(([, value]) => value !== undefined && value !== null)\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(' ')\n}\n\nexport function formatDirective(\n name: DirectiveName,\n props: Record<string, unknown>,\n label?: string,\n): string {\n const attrs = buildAttributes(props)\n if (label) {\n return attrs ? `:${name}[${label}]{${attrs}}` : `:${name}[${label}]`\n }\n return attrs ? `::${name}{${attrs}}` : `::${name}`\n}\n\nexport function createDocumentDirective(props: DocumentDirectiveProps, label?: string): string {\n return formatDirective(DIRECTIVE_NAMES.document, props, label)\n}\n\nexport function createReleaseDirective(props: ReleaseDirectiveProps, label?: string): string {\n return formatDirective(DIRECTIVE_NAMES.release, props, label)\n}\n\nexport function createResourceDirective(props: ResourceDirectiveProps): string {\n return formatDirective(DIRECTIVE_NAMES.resource, props)\n}\n\nexport function createSetDirective(props: SetDirectiveProps): string {\n return formatDirective(DIRECTIVE_NAMES.set, props)\n}\n\nexport function createChangesDirective(props: ChangesDirectiveProps): string {\n return formatDirective(DIRECTIVE_NAMES.changes, props)\n}\n\nexport function createRequestProjectAccessDirective(\n props: RequestProjectAccessDirectiveProps,\n): string {\n return formatDirective(DIRECTIVE_NAMES.requestProjectAccess, props)\n}\n"],"names":[],"mappings":";AAKO,MAAM,0BAA0B,EAAE,OAAO;AAAA,EAC9C,IAAI,EAAE,OAAA;AAAA,EACN,MAAM,EAAE,OAAA,EAAS,SAAA;AAAA,EACjB,QAAQ,EAAE,OAAA,EAAS,SAAA;AACrB,CAAC,GAEY,yBAAyB,EAAE,OAAO;AAAA,EAC7C,IAAI,EAAE,OAAA;AAAA,EACN,QAAQ,EAAE,OAAA,EAAS,SAAA;AACrB,CAAC,GAEY,0BAA0B,EAAE,OAAO;AAAA,EAC9C,QAAQ,EAAE,OAAA;AACZ,CAAC,GAEY,sCAAsC,EAAE,OAAO;AAAA,EAC1D,QAAQ,EAAE,OAAA;AACZ,CAAC,GAEY,qBAAqB,EAAE,OAAO;AAAA,EACzC,IAAI,EAAE,OAAA;AACR,CAAC,GAEY,yBAAyB,EAAE,OAAO;AAAA,EAC7C,cAAc,EAAE,OAAO,OAAA,EAAS,IAAI,CAAC;AAAA,EACrC,cAAc,EAAE,OAAO,OAAA,EAAS,IAAI,CAAC;AACvC,CAAC,GAEY,mBAAmB;AAAA,EAC9B,UAAU;AAAA,EACV,SAAS;AAAA,EACT,UAAU;AAAA,EACV,KAAK;AAAA,EACL,SAAS;AAAA,EACT,sBAAsB;
|
|
1
|
+
{"version":3,"file":"formatters.js","sources":["../../src/_internal/index.ts"],"sourcesContent":["// This internal module contains all shared code that both the main index\n// and sub-exports can import without causing self-referencing issues with pkg-utils\n\nimport { z } from 'zod'\n\nexport const DocumentDirectiveSchema = z.object({\n id: z.string(),\n type: z.string().optional(),\n source: z.string().optional(),\n})\n\nexport const ReleaseDirectiveSchema = z.object({\n id: z.string(),\n source: z.string().optional(),\n})\n\nexport const ResourceDirectiveSchema = z.object({\n source: z.string(),\n})\n\nexport const RequestProjectAccessDirectiveSchema = z.object({\n source: z.string(),\n})\n\nexport const SetDirectiveSchema = z.object({\n id: z.string(),\n})\n\nexport const ChangesDirectiveSchema = z.object({\n createdCount: z.coerce.number().min(0),\n updatedCount: z.coerce.number().min(0),\n})\n\nexport const ConfirmDirectiveSchema = z.object({\n status: z.enum(['pending', 'approved', 'cancelled']),\n toolCallId: z.string(),\n runId: z.string(),\n toolName: z.string(),\n data: z.string(), // base64-encoded JSON, typed per toolName\n})\n\nexport const DirectiveSchemas = {\n document: DocumentDirectiveSchema,\n release: ReleaseDirectiveSchema,\n resource: ResourceDirectiveSchema,\n set: SetDirectiveSchema,\n changes: ChangesDirectiveSchema,\n requestProjectAccess: RequestProjectAccessDirectiveSchema,\n confirm: ConfirmDirectiveSchema,\n} as const\n\nexport const DIRECTIVE_NAMES = {\n document: 'document',\n release: 'release',\n resource: 'resource',\n set: 'set',\n changes: 'changes',\n requestProjectAccess: 'requestProjectAccess',\n confirm: 'confirm',\n} as const\n\nexport const DIRECTIVE_TYPES = ['textDirective', 'leafDirective', 'containerDirective'] as const\n\nexport type DirectiveType = (typeof DIRECTIVE_TYPES)[number]\n\nexport type DirectiveName = (typeof DIRECTIVE_NAMES)[keyof typeof DIRECTIVE_NAMES]\n\nexport type DocumentDirectiveProps = z.infer<typeof DocumentDirectiveSchema>\nexport type ReleaseDirectiveProps = z.infer<typeof ReleaseDirectiveSchema>\nexport type ResourceDirectiveProps = z.infer<typeof ResourceDirectiveSchema>\nexport type SetDirectiveProps = z.infer<typeof SetDirectiveSchema>\nexport type ChangesDirectiveProps = z.infer<typeof ChangesDirectiveSchema>\nexport type RequestProjectAccessDirectiveProps = z.infer<typeof RequestProjectAccessDirectiveSchema>\nexport type ConfirmDirectiveProps = z.infer<typeof ConfirmDirectiveSchema>\n\nexport interface DirectivePropsMap {\n document: DocumentDirectiveProps\n release: ReleaseDirectiveProps\n resource: ResourceDirectiveProps\n set: SetDirectiveProps\n changes: ChangesDirectiveProps\n requestProjectAccess: RequestProjectAccessDirectiveProps\n confirm: ConfirmDirectiveProps\n}\n\nexport interface DefineDirectiveOptions {\n /**\n * Whether this directive requires context/application to render.\n * If true (default), the directive won't render without context.\n */\n requiresContext?: boolean\n /** @deprecated Use `requiresContext` instead */\n requiresApplication?: boolean\n}\n\n// Label content pattern: matches non-bracket chars or single-level nested [...]\n// e.g. \"Guide [E-commerce edition]\" matches, but won't span across \"] other text [\"\nconst LABEL = '(?:[^\\\\[\\\\]]|\\\\[[^\\\\[\\\\]]*\\\\])*'\n\n// Matches block directives: ::name{attrs} or ::name[label]{attrs}\n// Captures: (1) name, (2) label or undefined, (3) attribute string\nexport const BLOCK_DIRECTIVE = new RegExp(`::([a-zA-Z]\\\\w*)(?:\\\\[(${LABEL})\\\\])?\\\\{([^}]*)\\\\}`)\n\n// Matches inline directives: :name[label]{attrs}\n// Captures: (1) name, (2) label, (3) attribute string\nexport const INLINE_DIRECTIVE = new RegExp(`:([a-zA-Z]\\\\w*)\\\\[(${LABEL})\\\\]\\\\{([^}]*)\\\\}`)\n\nexport function parseDirectiveAttributes(attrString: string): Record<string, string> {\n const attrs: Record<string, string> = {}\n for (const match of attrString.matchAll(/(\\w+)=\"([^\"]*)\"/g)) {\n attrs[match[1]] = match[2]\n }\n return attrs\n}\n\nfunction buildAttributes(params: Record<string, unknown>): string {\n return Object.entries(params)\n .filter(([, value]) => value !== undefined && value !== null)\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(' ')\n}\n\nexport function formatDirective(\n name: DirectiveName,\n props: Record<string, unknown>,\n label?: string,\n): string {\n const attrs = buildAttributes(props)\n if (label) {\n return attrs ? `:${name}[${label}]{${attrs}}` : `:${name}[${label}]`\n }\n return attrs ? `::${name}{${attrs}}` : `::${name}`\n}\n\nexport function createDocumentDirective(props: DocumentDirectiveProps, label?: string): string {\n return formatDirective(DIRECTIVE_NAMES.document, props, label)\n}\n\nexport function createReleaseDirective(props: ReleaseDirectiveProps, label?: string): string {\n return formatDirective(DIRECTIVE_NAMES.release, props, label)\n}\n\nexport function createResourceDirective(props: ResourceDirectiveProps): string {\n return formatDirective(DIRECTIVE_NAMES.resource, props)\n}\n\nexport function createSetDirective(props: SetDirectiveProps): string {\n return formatDirective(DIRECTIVE_NAMES.set, props)\n}\n\nexport function createChangesDirective(props: ChangesDirectiveProps): string {\n return formatDirective(DIRECTIVE_NAMES.changes, props)\n}\n\nexport function createRequestProjectAccessDirective(\n props: RequestProjectAccessDirectiveProps,\n): string {\n return formatDirective(DIRECTIVE_NAMES.requestProjectAccess, props)\n}\n\nexport function createConfirmDirective(props: ConfirmDirectiveProps, label?: string): string {\n return formatDirective(DIRECTIVE_NAMES.confirm, props, label)\n}\n"],"names":[],"mappings":";AAKO,MAAM,0BAA0B,EAAE,OAAO;AAAA,EAC9C,IAAI,EAAE,OAAA;AAAA,EACN,MAAM,EAAE,OAAA,EAAS,SAAA;AAAA,EACjB,QAAQ,EAAE,OAAA,EAAS,SAAA;AACrB,CAAC,GAEY,yBAAyB,EAAE,OAAO;AAAA,EAC7C,IAAI,EAAE,OAAA;AAAA,EACN,QAAQ,EAAE,OAAA,EAAS,SAAA;AACrB,CAAC,GAEY,0BAA0B,EAAE,OAAO;AAAA,EAC9C,QAAQ,EAAE,OAAA;AACZ,CAAC,GAEY,sCAAsC,EAAE,OAAO;AAAA,EAC1D,QAAQ,EAAE,OAAA;AACZ,CAAC,GAEY,qBAAqB,EAAE,OAAO;AAAA,EACzC,IAAI,EAAE,OAAA;AACR,CAAC,GAEY,yBAAyB,EAAE,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AACnC,SAAI,QACK,QAAQ,IAAI,IAAI,IAAI,KAAK,KAAK,KAAK,MAAM,IAAI,IAAI,IAAI,KAAK,MAE5D,QAAQ,KAAK,IAAI,IAAI,KAAK,MAAM,KAAK,IAAI;AAClD;AAEO,SAAS,wBAAwB,OAA+B,OAAwB;AAC7F,SAAO,gBAAgB,gBAAgB,UAAU,OAAO,KAAK;AAC/D;AAEO,SAAS,uBAAuB,OAA8B,OAAwB;AAC3F,SAAO,gBAAgB,gBAAgB,SAAS,OAAO,KAAK;AAC9D;AAEO,SAAS,wBAAwB,OAAuC;AAC7E,SAAO,gBAAgB,gBAAgB,UAAU,KAAK;AACxD;AAEO,SAAS,mBAAmB,OAAkC;AACnE,SAAO,gBAAgB,gBAAgB,KAAK,KAAK;AACnD;AAEO,SAAS,uBAAuB,OAAsC;AAC3E,SAAO,gBAAgB,gBAAgB,SAAS,KAAK;AACvD;AAEO,SAAS,oCACd,OACQ;AACR,SAAO,gBAAgB,gBAAgB,sBAAsB,KAAK;AACpE;AAEO,SAAS,uBAAuB,OAA8B,OAAwB;AAC3F,SAAO,gBAAgB,gBAAgB,SAAS,OAAO,KAAK;AAC9D;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { E as formatDirective, S as createReleaseDirective, T as createSetDirective, _ as SetDirectiveProps, a as DIRECTIVE_NAMES, b as createConfirmDirective, c as DirectivePropsMap, d as DocumentDirectiveSchema, f as ReleaseDirectiveProps, g as ResourceDirectiveSchema, h as ResourceDirectiveProps, i as ConfirmDirectiveSchema, l as DirectiveSchemas, n as ChangesDirectiveSchema, o as DefineDirectiveOptions, p as ReleaseDirectiveSchema, r as ConfirmDirectiveProps, s as DirectiveName, t as ChangesDirectiveProps, u as DocumentDirectiveProps, v as SetDirectiveSchema, w as createResourceDirective, x as createDocumentDirective, y as createChangesDirective } from "./_chunks-dts/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Scans `text` for block directives (`::name{attrs}`) of the given type,
|
|
4
4
|
* validates each match through its Zod schema, and returns the parsed props.
|
|
5
5
|
*/
|
|
6
6
|
declare function findDirectives<N extends keyof DirectivePropsMap>(text: string, name: N): DirectivePropsMap[N][];
|
|
7
|
-
export { type ChangesDirectiveProps, ChangesDirectiveSchema, DIRECTIVE_NAMES, type DefineDirectiveOptions, type DirectiveName, type DirectivePropsMap, DirectiveSchemas, type DocumentDirectiveProps, DocumentDirectiveSchema, type ReleaseDirectiveProps, ReleaseDirectiveSchema, type ResourceDirectiveProps, ResourceDirectiveSchema, type SetDirectiveProps, SetDirectiveSchema, createChangesDirective, createDocumentDirective, createReleaseDirective, createResourceDirective, createSetDirective, findDirectives, formatDirective };
|
|
7
|
+
export { type ChangesDirectiveProps, ChangesDirectiveSchema, type ConfirmDirectiveProps, ConfirmDirectiveSchema, DIRECTIVE_NAMES, type DefineDirectiveOptions, type DirectiveName, type DirectivePropsMap, DirectiveSchemas, type DocumentDirectiveProps, DocumentDirectiveSchema, type ReleaseDirectiveProps, ReleaseDirectiveSchema, type ResourceDirectiveProps, ResourceDirectiveSchema, type SetDirectiveProps, SetDirectiveSchema, createChangesDirective, createConfirmDirective, createDocumentDirective, createReleaseDirective, createResourceDirective, createSetDirective, findDirectives, formatDirective };
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseDirectiveAttributes, DirectiveSchemas, BLOCK_DIRECTIVE } from "./_chunks-es/formatters.js";
|
|
2
|
-
import { ChangesDirectiveSchema, DIRECTIVE_NAMES, DocumentDirectiveSchema, ReleaseDirectiveSchema, ResourceDirectiveSchema, SetDirectiveSchema, createChangesDirective, createDocumentDirective, createReleaseDirective, createResourceDirective, createSetDirective, formatDirective } from "./_chunks-es/formatters.js";
|
|
2
|
+
import { ChangesDirectiveSchema, ConfirmDirectiveSchema, DIRECTIVE_NAMES, DocumentDirectiveSchema, ReleaseDirectiveSchema, ResourceDirectiveSchema, SetDirectiveSchema, createChangesDirective, createConfirmDirective, createDocumentDirective, createReleaseDirective, createResourceDirective, createSetDirective, formatDirective } from "./_chunks-es/formatters.js";
|
|
3
3
|
function findDirectives(text, name) {
|
|
4
4
|
const regex = new RegExp(BLOCK_DIRECTIVE.source, "g"), schema = DirectiveSchemas[name], results = [];
|
|
5
5
|
for (const match of text.matchAll(regex)) {
|
|
@@ -11,6 +11,7 @@ function findDirectives(text, name) {
|
|
|
11
11
|
}
|
|
12
12
|
export {
|
|
13
13
|
ChangesDirectiveSchema,
|
|
14
|
+
ConfirmDirectiveSchema,
|
|
14
15
|
DIRECTIVE_NAMES,
|
|
15
16
|
DirectiveSchemas,
|
|
16
17
|
DocumentDirectiveSchema,
|
|
@@ -18,6 +19,7 @@ export {
|
|
|
18
19
|
ResourceDirectiveSchema,
|
|
19
20
|
SetDirectiveSchema,
|
|
20
21
|
createChangesDirective,
|
|
22
|
+
createConfirmDirective,
|
|
21
23
|
createDocumentDirective,
|
|
22
24
|
createReleaseDirective,
|
|
23
25
|
createResourceDirective,
|
package/dist/lib/formatters.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as formatDirective, S as createSetDirective, _ as
|
|
2
|
-
export { type ChangesDirectiveProps, DIRECTIVE_NAMES, type DirectiveName, type DocumentDirectiveProps, type ReleaseDirectiveProps, type RequestProjectAccessDirectiveProps, type ResourceDirectiveProps, type SetDirectiveProps, createChangesDirective, createDocumentDirective, createReleaseDirective, createRequestProjectAccessDirective, createResourceDirective, createSetDirective, formatDirective };
|
|
1
|
+
import { C as createRequestProjectAccessDirective, E as formatDirective, S as createReleaseDirective, T as createSetDirective, _ as SetDirectiveProps, a as DIRECTIVE_NAMES, b as createConfirmDirective, f as ReleaseDirectiveProps, h as ResourceDirectiveProps, m as RequestProjectAccessDirectiveProps, r as ConfirmDirectiveProps, s as DirectiveName, t as ChangesDirectiveProps, u as DocumentDirectiveProps, w as createResourceDirective, x as createDocumentDirective, y as createChangesDirective } from "../_chunks-dts/index.js";
|
|
2
|
+
export { type ChangesDirectiveProps, type ConfirmDirectiveProps, DIRECTIVE_NAMES, type DirectiveName, type DocumentDirectiveProps, type ReleaseDirectiveProps, type RequestProjectAccessDirectiveProps, type ResourceDirectiveProps, type SetDirectiveProps, createChangesDirective, createConfirmDirective, createDocumentDirective, createReleaseDirective, createRequestProjectAccessDirective, createResourceDirective, createSetDirective, formatDirective };
|
package/dist/lib/formatters.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { DIRECTIVE_NAMES, createChangesDirective, createDocumentDirective, createReleaseDirective, createRequestProjectAccessDirective, createResourceDirective, createSetDirective, formatDirective } from "../_chunks-es/formatters.js";
|
|
1
|
+
import { DIRECTIVE_NAMES, createChangesDirective, createConfirmDirective, createDocumentDirective, createReleaseDirective, createRequestProjectAccessDirective, createResourceDirective, createSetDirective, formatDirective } from "../_chunks-es/formatters.js";
|
|
2
2
|
export {
|
|
3
3
|
DIRECTIVE_NAMES,
|
|
4
4
|
createChangesDirective,
|
|
5
|
+
createConfirmDirective,
|
|
5
6
|
createDocumentDirective,
|
|
6
7
|
createReleaseDirective,
|
|
7
8
|
createRequestProjectAccessDirective,
|
package/dist/lib/react.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as DirectivePropsMap, o as DefineDirectiveOptions, s as DirectiveName } from "../_chunks-dts/index.js";
|
|
2
2
|
import { ComponentType, ReactNode } from "react";
|
|
3
3
|
import { Processor } from "unified";
|
|
4
4
|
import { Node } from "unist";
|
package/dist/lib/server.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as DirectivePropsMap, o as DefineDirectiveOptions, s as DirectiveName } from "../_chunks-dts/index.js";
|
|
2
2
|
import { Root } from "mdast";
|
|
3
3
|
type DirectiveProps<T extends DirectiveName> = DirectivePropsMap[T];
|
|
4
4
|
interface DirectiveNode {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/agent-directives",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"description": "Shared directive system for Sanity Agent",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"es-toolkit": "^1.
|
|
40
|
+
"es-toolkit": "^1.44.0",
|
|
41
41
|
"mdast-util-directive": "^3.0.0",
|
|
42
42
|
"micromark-extension-directive": "^3.0.0",
|
|
43
43
|
"remark-directive": "^3.0.0",
|