@sanity/agent-directives 0.0.7 → 0.0.9

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.
@@ -29,6 +29,13 @@ declare const ResourceDirectiveSchema: z.ZodObject<{
29
29
  }, {
30
30
  source: string;
31
31
  }>;
32
+ declare const RequestProjectAccessDirectiveSchema: z.ZodObject<{
33
+ source: z.ZodString;
34
+ }, "strip", z.ZodTypeAny, {
35
+ source: string;
36
+ }, {
37
+ source: string;
38
+ }>;
32
39
  declare const SetDirectiveSchema: z.ZodObject<{
33
40
  id: z.ZodString;
34
41
  }, "strip", z.ZodTypeAny, {
@@ -94,6 +101,13 @@ declare const DirectiveSchemas: {
94
101
  createdCount: number;
95
102
  updatedCount: number;
96
103
  }>;
104
+ readonly requestProjectAccess: z.ZodObject<{
105
+ source: z.ZodString;
106
+ }, "strip", z.ZodTypeAny, {
107
+ source: string;
108
+ }, {
109
+ source: string;
110
+ }>;
97
111
  };
98
112
  declare const DIRECTIVE_NAMES: {
99
113
  readonly document: "document";
@@ -101,6 +115,7 @@ declare const DIRECTIVE_NAMES: {
101
115
  readonly resource: "resource";
102
116
  readonly set: "set";
103
117
  readonly changes: "changes";
118
+ readonly requestProjectAccess: "requestProjectAccess";
104
119
  };
105
120
  type DirectiveName = (typeof DIRECTIVE_NAMES)[keyof typeof DIRECTIVE_NAMES];
106
121
  type DocumentDirectiveProps = z.infer<typeof DocumentDirectiveSchema>;
@@ -108,12 +123,14 @@ type ReleaseDirectiveProps = z.infer<typeof ReleaseDirectiveSchema>;
108
123
  type ResourceDirectiveProps = z.infer<typeof ResourceDirectiveSchema>;
109
124
  type SetDirectiveProps = z.infer<typeof SetDirectiveSchema>;
110
125
  type ChangesDirectiveProps = z.infer<typeof ChangesDirectiveSchema>;
126
+ type RequestProjectAccessDirectiveProps = z.infer<typeof RequestProjectAccessDirectiveSchema>;
111
127
  interface DirectivePropsMap {
112
128
  document: DocumentDirectiveProps;
113
129
  release: ReleaseDirectiveProps;
114
130
  resource: ResourceDirectiveProps;
115
131
  set: SetDirectiveProps;
116
132
  changes: ChangesDirectiveProps;
133
+ requestProjectAccess: RequestProjectAccessDirectiveProps;
117
134
  }
118
135
  interface DefineDirectiveOptions {
119
136
  /**
@@ -124,11 +141,12 @@ interface DefineDirectiveOptions {
124
141
  /** @deprecated Use `requiresContext` instead */
125
142
  requiresApplication?: boolean;
126
143
  }
127
- declare function formatDirective(name: DirectiveName, props: Record<string, unknown>): string;
128
- declare function createDocumentDirective(props: DocumentDirectiveProps): string;
129
- declare function createReleaseDirective(props: ReleaseDirectiveProps): string;
144
+ declare function formatDirective(name: DirectiveName, props: Record<string, unknown>, label?: string): string;
145
+ declare function createDocumentDirective(props: DocumentDirectiveProps, label?: string): string;
146
+ declare function createReleaseDirective(props: ReleaseDirectiveProps, label?: string): string;
130
147
  declare function createResourceDirective(props: ResourceDirectiveProps): string;
131
148
  declare function createSetDirective(props: SetDirectiveProps): string;
132
149
  declare function createChangesDirective(props: ChangesDirectiveProps): string;
133
- export { createDocumentDirective as _, DirectiveName as a, createSetDirective as b, DocumentDirectiveProps as c, ReleaseDirectiveSchema as d, ResourceDirectiveProps as f, createChangesDirective as g, SetDirectiveSchema as h, DefineDirectiveOptions as i, DocumentDirectiveSchema as l, SetDirectiveProps as m, ChangesDirectiveSchema as n, DirectivePropsMap as o, ResourceDirectiveSchema as p, DIRECTIVE_NAMES as r, DirectiveSchemas as s, ChangesDirectiveProps as t, ReleaseDirectiveProps as u, createReleaseDirective as v, formatDirective as x, createResourceDirective as y };
150
+ declare function createRequestProjectAccessDirective(props: RequestProjectAccessDirectiveProps): string;
151
+ export { formatDirective as C, createSetDirective as S, createChangesDirective as _, DirectiveName as a, createRequestProjectAccessDirective as b, DocumentDirectiveProps as c, ReleaseDirectiveSchema as d, RequestProjectAccessDirectiveProps as f, SetDirectiveSchema as g, SetDirectiveProps as h, DefineDirectiveOptions as i, DocumentDirectiveSchema as l, ResourceDirectiveSchema as m, ChangesDirectiveSchema as n, DirectivePropsMap as o, ResourceDirectiveProps as p, DIRECTIVE_NAMES as r, DirectiveSchemas as s, ChangesDirectiveProps as t, ReleaseDirectiveProps as u, createDocumentDirective as v, createResourceDirective as x, createReleaseDirective as y };
134
152
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/_internal/index.ts"],"mappings":";cASa,uBAAA,EAAuB,CAAA,CAAA,SAAA;;;;;;;;;;;;;cAMvB,sBAAA,EAAsB,CAAA,CAAA,SAAA;;;;;;;;;;cAKtB,uBAAA,EAAuB,CAAA,CAAA,SAAA;;;;;;;cAIvB,kBAAA,EAAkB,CAAA,CAAA,SAAA;;;;;;;cAIlB,sBAAA,EAAsB,CAAA,CAAA,SAAA;;;;;;;;;;cAKtB,gBAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAQA,eAAA;EAAA;;;;;;KAYD,aAAA,WAAwB,eAAA,eAA8B,eAAA;AAAA,KAEtD,sBAAA,GAAyB,CAAA,CAAE,KAAA,QAAa,uBAAA;AAAA,KACxC,qBAAA,GAAwB,CAAA,CAAE,KAAA,QAAa,sBAAA;AAAA,KACvC,sBAAA,GAAyB,CAAA,CAAE,KAAA,QAAa,uBAAA;AAAA,KACxC,iBAAA,GAAoB,CAAA,CAAE,KAAA,QAAa,kBAAA;AAAA,KACnC,qBAAA,GAAwB,CAAA,CAAE,KAAA,QAAa,sBAAA;AAAA,UAElC,iBAAA;EACf,QAAA,EAAU,sBAAA;EACV,OAAA,EAAS,qBAAA;EACT,QAAA,EAAU,sBAAA;EACV,GAAA,EAAK,iBAAA;EACL,OAAA,EAAS,qBAAA;AAAA;AAAA,UAGM,sBAAA;;;;;EAKf,eAAA;;EAEA,mBAAA;AAAA;AAAA,iBAcc,eAAA,CAAgB,IAAA,EAAM,aAAA,EAAe,KAAA,EAAO,MAAA;AAAA,iBAK5C,uBAAA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kCAAA;AAAA;AAAA,UAGP,sBAAA;;;;;EAKf,eAAA;;EAEA,mBAAA;AAAA;AAAA,iBAcc,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"}
@@ -0,0 +1,75 @@
1
+ import { z } from "zod";
2
+ const DocumentDirectiveSchema = z.object({
3
+ id: z.string(),
4
+ type: z.string().optional(),
5
+ source: z.string().optional()
6
+ }), ReleaseDirectiveSchema = z.object({
7
+ id: z.string(),
8
+ source: z.string().optional()
9
+ }), ResourceDirectiveSchema = z.object({
10
+ source: z.string()
11
+ }), RequestProjectAccessDirectiveSchema = z.object({
12
+ source: z.string()
13
+ }), SetDirectiveSchema = z.object({
14
+ id: z.string()
15
+ }), ChangesDirectiveSchema = z.object({
16
+ createdCount: z.coerce.number().min(0),
17
+ updatedCount: z.coerce.number().min(0)
18
+ }), DirectiveSchemas = {
19
+ document: DocumentDirectiveSchema,
20
+ release: ReleaseDirectiveSchema,
21
+ resource: ResourceDirectiveSchema,
22
+ set: SetDirectiveSchema,
23
+ changes: ChangesDirectiveSchema,
24
+ requestProjectAccess: RequestProjectAccessDirectiveSchema
25
+ }, DIRECTIVE_NAMES = {
26
+ document: "document",
27
+ release: "release",
28
+ resource: "resource",
29
+ set: "set",
30
+ changes: "changes",
31
+ requestProjectAccess: "requestProjectAccess"
32
+ }, DIRECTIVE_TYPES = ["textDirective", "leafDirective", "containerDirective"];
33
+ function buildAttributes(params) {
34
+ return Object.entries(params).filter(([, value]) => value != null).map(([key, value]) => `${key}="${value}"`).join(" ");
35
+ }
36
+ function formatDirective(name, props, label) {
37
+ const attrs = buildAttributes(props);
38
+ return label ? attrs ? `:${name}[${label}]{${attrs}}` : `:${name}[${label}]` : attrs ? `::${name}{${attrs}}` : `::${name}`;
39
+ }
40
+ function createDocumentDirective(props, label) {
41
+ return formatDirective(DIRECTIVE_NAMES.document, props, label);
42
+ }
43
+ function createReleaseDirective(props, label) {
44
+ return formatDirective(DIRECTIVE_NAMES.release, props, label);
45
+ }
46
+ function createResourceDirective(props) {
47
+ return formatDirective(DIRECTIVE_NAMES.resource, props);
48
+ }
49
+ function createSetDirective(props) {
50
+ return formatDirective(DIRECTIVE_NAMES.set, props);
51
+ }
52
+ function createChangesDirective(props) {
53
+ return formatDirective(DIRECTIVE_NAMES.changes, props);
54
+ }
55
+ function createRequestProjectAccessDirective(props) {
56
+ return formatDirective(DIRECTIVE_NAMES.requestProjectAccess, props);
57
+ }
58
+ export {
59
+ ChangesDirectiveSchema,
60
+ DIRECTIVE_NAMES,
61
+ DIRECTIVE_TYPES,
62
+ DirectiveSchemas,
63
+ DocumentDirectiveSchema,
64
+ ReleaseDirectiveSchema,
65
+ ResourceDirectiveSchema,
66
+ SetDirectiveSchema,
67
+ createChangesDirective,
68
+ createDocumentDirective,
69
+ createReleaseDirective,
70
+ createRequestProjectAccessDirective,
71
+ createResourceDirective,
72
+ createSetDirective,
73
+ formatDirective
74
+ };
75
+ //# sourceMappingURL=formatters.js.map
@@ -0,0 +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\n// ============================================================================\n// Schemas\n// ============================================================================\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\n// ============================================================================\n// Types\n// ============================================================================\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// ============================================================================\n// Formatter Functions\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":";AASO,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,OAA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AAU,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;"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as createDocumentDirective, a as DirectiveName, b as createSetDirective, c as DocumentDirectiveProps, d as ReleaseDirectiveSchema, f as ResourceDirectiveProps, g as createChangesDirective, h as SetDirectiveSchema, i as DefineDirectiveOptions, l as DocumentDirectiveSchema, m as SetDirectiveProps, n as ChangesDirectiveSchema, o as DirectivePropsMap, p as ResourceDirectiveSchema, r as DIRECTIVE_NAMES, s as DirectiveSchemas, t as ChangesDirectiveProps, u as ReleaseDirectiveProps, v as createReleaseDirective, x as formatDirective, y as createResourceDirective } from "./_chunks-dts/index.js";
1
+ import { C as formatDirective, S as createSetDirective, _ as createChangesDirective, a as DirectiveName, c as DocumentDirectiveProps, d as ReleaseDirectiveSchema, g as SetDirectiveSchema, h as SetDirectiveProps, i as DefineDirectiveOptions, l as DocumentDirectiveSchema, m as ResourceDirectiveSchema, n as ChangesDirectiveSchema, o as DirectivePropsMap, p as ResourceDirectiveProps, r as DIRECTIVE_NAMES, s as DirectiveSchemas, t as ChangesDirectiveProps, u as ReleaseDirectiveProps, v as createDocumentDirective, x as createResourceDirective, y as createReleaseDirective } from "./_chunks-dts/index.js";
2
2
  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, formatDirective };
package/dist/index.js CHANGED
@@ -1,53 +1,4 @@
1
- import { z } from "zod";
2
- const DocumentDirectiveSchema = z.object({
3
- id: z.string(),
4
- type: z.string().optional(),
5
- source: z.string().optional()
6
- }), ReleaseDirectiveSchema = z.object({
7
- id: z.string(),
8
- source: z.string().optional()
9
- }), ResourceDirectiveSchema = z.object({
10
- source: z.string()
11
- }), SetDirectiveSchema = z.object({
12
- id: z.string()
13
- }), ChangesDirectiveSchema = z.object({
14
- createdCount: z.coerce.number().min(0),
15
- updatedCount: z.coerce.number().min(0)
16
- }), DirectiveSchemas = {
17
- document: DocumentDirectiveSchema,
18
- release: ReleaseDirectiveSchema,
19
- resource: ResourceDirectiveSchema,
20
- set: SetDirectiveSchema,
21
- changes: ChangesDirectiveSchema
22
- }, DIRECTIVE_NAMES = {
23
- document: "document",
24
- release: "release",
25
- resource: "resource",
26
- set: "set",
27
- changes: "changes"
28
- };
29
- function buildAttributes(params) {
30
- return Object.entries(params).filter(([, value]) => value != null).map(([key, value]) => `${key}="${value}"`).join(" ");
31
- }
32
- function formatDirective(name, props) {
33
- const attrs = buildAttributes(props);
34
- return attrs ? `::${name}{${attrs}}` : `::${name}`;
35
- }
36
- function createDocumentDirective(props) {
37
- return formatDirective(DIRECTIVE_NAMES.document, props);
38
- }
39
- function createReleaseDirective(props) {
40
- return formatDirective(DIRECTIVE_NAMES.release, props);
41
- }
42
- function createResourceDirective(props) {
43
- return formatDirective(DIRECTIVE_NAMES.resource, props);
44
- }
45
- function createSetDirective(props) {
46
- return formatDirective(DIRECTIVE_NAMES.set, props);
47
- }
48
- function createChangesDirective(props) {
49
- return formatDirective(DIRECTIVE_NAMES.changes, props);
50
- }
1
+ import { ChangesDirectiveSchema, DIRECTIVE_NAMES, DirectiveSchemas, DocumentDirectiveSchema, ReleaseDirectiveSchema, ResourceDirectiveSchema, SetDirectiveSchema, createChangesDirective, createDocumentDirective, createReleaseDirective, createResourceDirective, createSetDirective, formatDirective } from "./_chunks-es/formatters.js";
51
2
  export {
52
3
  ChangesDirectiveSchema,
53
4
  DIRECTIVE_NAMES,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.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\n// ============================================================================\n// Schemas\n// ============================================================================\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 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} as const\n\nexport const DIRECTIVE_NAMES = {\n document: 'document',\n release: 'release',\n resource: 'resource',\n set: 'set',\n changes: 'changes',\n} as const\n\n// ============================================================================\n// Types\n// ============================================================================\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>\n\nexport interface DirectivePropsMap {\n document: DocumentDirectiveProps\n release: ReleaseDirectiveProps\n resource: ResourceDirectiveProps\n set: SetDirectiveProps\n changes: ChangesDirectiveProps\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// ============================================================================\n// Formatter Functions\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(name: DirectiveName, props: Record<string, unknown>): string {\n const attrs = buildAttributes(props)\n return attrs ? `::${name}{${attrs}}` : `::${name}`\n}\n\nexport function createDocumentDirective(props: DocumentDirectiveProps): string {\n return formatDirective(DIRECTIVE_NAMES.document, props)\n}\n\nexport function createReleaseDirective(props: ReleaseDirectiveProps): string {\n return formatDirective(DIRECTIVE_NAMES.release, props)\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"],"names":[],"mappings":";AASO,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,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;AACX,GAEa,kBAAkB;AAAA,EAC7B,UAAU;AAAA,EACV,SAAS;AAAA,EACT,UAAU;AAAA,EACV,KAAK;AAAA,EACL,SAAS;AACX;AAoCA,SAAS,gBAAgB,QAAyC;AAChE,SAAO,OAAO,QAAQ,MAAM,EACzB,OAAO,CAAC,CAAA,EAAG,KAAK,MAA6B,SAAU,IAAI,EAC3D,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,GAAG,GAAG,KAAK,KAAK,GAAG,EACzC,KAAK,GAAG;AACb;AAEO,SAAS,gBAAgB,MAAqB,OAAwC;AAC3F,QAAM,QAAQ,gBAAgB,KAAK;AACnC,SAAO,QAAQ,KAAK,IAAI,IAAI,KAAK,MAAM,KAAK,IAAI;AAClD;AAEO,SAAS,wBAAwB,OAAuC;AAC7E,SAAO,gBAAgB,gBAAgB,UAAU,KAAK;AACxD;AAEO,SAAS,uBAAuB,OAAsC;AAC3E,SAAO,gBAAgB,gBAAgB,SAAS,KAAK;AACvD;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;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,2 +1,2 @@
1
- import { _ as createDocumentDirective, a as DirectiveName, b as createSetDirective, c as DocumentDirectiveProps, f as ResourceDirectiveProps, g as createChangesDirective, m as SetDirectiveProps, r as DIRECTIVE_NAMES, t as ChangesDirectiveProps, u as ReleaseDirectiveProps, v as createReleaseDirective, x as formatDirective, y as createResourceDirective } from "../_chunks-dts/index.js";
2
- export { type ChangesDirectiveProps, DIRECTIVE_NAMES, type DirectiveName, type DocumentDirectiveProps, type ReleaseDirectiveProps, type ResourceDirectiveProps, type SetDirectiveProps, createChangesDirective, createDocumentDirective, createReleaseDirective, createResourceDirective, createSetDirective, formatDirective };
1
+ import { C as formatDirective, S as createSetDirective, _ as createChangesDirective, a as DirectiveName, b as createRequestProjectAccessDirective, c as DocumentDirectiveProps, f as RequestProjectAccessDirectiveProps, h as SetDirectiveProps, p as ResourceDirectiveProps, r as DIRECTIVE_NAMES, t as ChangesDirectiveProps, u as ReleaseDirectiveProps, v as createDocumentDirective, x as createResourceDirective, y as createReleaseDirective } from "../_chunks-dts/index.js";
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,9 +1,10 @@
1
- import { DIRECTIVE_NAMES, createChangesDirective, createDocumentDirective, createReleaseDirective, createResourceDirective, createSetDirective, formatDirective } from "../index.js";
1
+ import { DIRECTIVE_NAMES, createChangesDirective, createDocumentDirective, createReleaseDirective, createRequestProjectAccessDirective, createResourceDirective, createSetDirective, formatDirective } from "../_chunks-es/formatters.js";
2
2
  export {
3
3
  DIRECTIVE_NAMES,
4
4
  createChangesDirective,
5
5
  createDocumentDirective,
6
6
  createReleaseDirective,
7
+ createRequestProjectAccessDirective,
7
8
  createResourceDirective,
8
9
  createSetDirective,
9
10
  formatDirective