@power-plant/core 0.0.12 → 0.0.16

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 (42) hide show
  1. package/README.md +1 -1
  2. package/dist/{config-DMItzxbk.d.cts → config-B_E87BPl.d.cts} +62 -238
  3. package/dist/config-B_E87BPl.d.cts.map +1 -0
  4. package/dist/{config-DMItzxbk.d.mts → config-B_E87BPl.d.mts} +62 -238
  5. package/dist/config-B_E87BPl.d.mts.map +1 -0
  6. package/dist/config.d.cts +1 -1
  7. package/dist/config.d.mts +1 -1
  8. package/dist/context-BCW5TgL-.d.mts +183 -0
  9. package/dist/context-BCW5TgL-.d.mts.map +1 -0
  10. package/dist/context-C0n9Tore.d.cts +183 -0
  11. package/dist/context-C0n9Tore.d.cts.map +1 -0
  12. package/dist/context.cjs +1 -1
  13. package/dist/context.d.cts +34 -2
  14. package/dist/context.d.cts.map +1 -1
  15. package/dist/context.d.mts +34 -2
  16. package/dist/context.mjs +1 -1
  17. package/dist/define.d.cts +2 -2
  18. package/dist/define.d.cts.map +1 -1
  19. package/dist/define.d.mts +2 -2
  20. package/dist/index.cjs +1 -1
  21. package/dist/index.d.cts +5 -26
  22. package/dist/index.d.mts +5 -26
  23. package/dist/index.mjs +1 -1
  24. package/dist/{type-checks-E_UZ_-fD.d.cts → type-checks-BYCnzjxr.d.cts} +4 -4
  25. package/dist/{type-checks-E_UZ_-fD.d.cts.map → type-checks-BYCnzjxr.d.cts.map} +1 -1
  26. package/dist/{type-checks-SBt7tgFq.d.mts → type-checks-C-wRp-HW.d.mts} +4 -4
  27. package/dist/type-checks-C-wRp-HW.d.mts.map +1 -0
  28. package/dist/type-checks.d.cts +1 -1
  29. package/dist/type-checks.d.mts +1 -1
  30. package/dist/types/__internal.d.cts +4 -4
  31. package/dist/types/__internal.d.cts.map +1 -1
  32. package/dist/types/__internal.d.mts +4 -4
  33. package/package.json +5 -5
  34. package/dist/config-DMItzxbk.d.cts.map +0 -1
  35. package/dist/config-DMItzxbk.d.mts.map +0 -1
  36. package/dist/context-BxqCoy9z.d.cts +0 -128
  37. package/dist/context-BxqCoy9z.d.cts.map +0 -1
  38. package/dist/context-COQtFcI5.d.mts +0 -128
  39. package/dist/context-COQtFcI5.d.mts.map +0 -1
  40. package/dist/index.d.cts.map +0 -1
  41. package/dist/index.d.mts.map +0 -1
  42. package/dist/type-checks-SBt7tgFq.d.mts.map +0 -1
@@ -0,0 +1,183 @@
1
+ import { B as SchemaMetaConfig, H as SchemaOf, M as Input, W as MetaConfig, c as Settings, m as GeneratedDocument, s as Logger, u as Output, x as GeneratorMeta } from "./config-B_E87BPl.mjs";
2
+ import { Storage } from "unstorage";
3
+ //#region src/types/execution.d.ts
4
+ interface ExecutionDocumentChunk {
5
+ /**
6
+ * The content of the chunk.
7
+ */
8
+ content: string;
9
+ /**
10
+ * The metadata of the chunk.
11
+ */
12
+ meta: MetaConfig;
13
+ }
14
+ interface ExecutionDocument {
15
+ /**
16
+ * The path of the document.
17
+ */
18
+ path: string;
19
+ /**
20
+ * The language of the document.
21
+ */
22
+ language?: string;
23
+ /**
24
+ * The chunks of the document.
25
+ */
26
+ chunks: ExecutionDocumentChunk[];
27
+ /**
28
+ * The metadata of the document.
29
+ */
30
+ meta: MetaConfig;
31
+ }
32
+ interface ExecutionMeta<TSpec, TOptions extends object> extends MetaConfig {
33
+ /**
34
+ * A unique identifier for the execution, typically used by the backend systems.
35
+ *
36
+ * @remarks
37
+ * This value will be in the UUID format, which is a 128-bit number represented as a string of hexadecimal digits. It is used to uniquely identify the execution in the backend systems and can be used for tracking and auditing purposes.
38
+ */
39
+ executionId: string;
40
+ /**
41
+ * The date and time when the execution was performed.
42
+ */
43
+ executedAt: Date;
44
+ /**
45
+ * The user who performed the execution.
46
+ */
47
+ executedBy: string;
48
+ /**
49
+ * The specification used to generate the source code during the execution.
50
+ */
51
+ spec: TSpec;
52
+ /**
53
+ * The metadata of the generator used to execute the source code during the execution.
54
+ */
55
+ generator: GeneratorMeta<TSpec, TOptions>;
56
+ /**
57
+ * The metadata of the schema used to generate the source code during the execution.
58
+ */
59
+ schema: SchemaMetaConfig<TSpec>;
60
+ /**
61
+ * The metadata of the input used to generate the source code during the execution.
62
+ */
63
+ input: MetaConfig;
64
+ /**
65
+ * The metadata of the output used to generate the source code during the execution.
66
+ */
67
+ output: MetaConfig;
68
+ }
69
+ interface Execution<TSpec, TOptions extends object> {
70
+ /**
71
+ * The documents of the execution, indexed by the document path.
72
+ */
73
+ documents: Record<string, ExecutionDocument>;
74
+ /**
75
+ * The metadata of the execution.
76
+ */
77
+ meta: ExecutionMeta<TSpec, TOptions>;
78
+ }
79
+ type ExecutionResult<TSpec, TOptions extends object, TReturns = void> = GeneratedDocument<TSpec, TOptions> & {
80
+ /**
81
+ * The returned value of the generator function.
82
+ */
83
+ returns?: TReturns;
84
+ };
85
+ //#endregion
86
+ //#region src/types/base.d.ts
87
+ interface Base {
88
+ /**
89
+ * A unique identifier for the model.
90
+ */
91
+ id: string;
92
+ /**
93
+ * The timestamp when the model was created.
94
+ */
95
+ createdAt: Date;
96
+ /**
97
+ * The timestamp when the model was last updated.
98
+ */
99
+ updatedAt: Date;
100
+ /**
101
+ * The description of the model.
102
+ */
103
+ description?: string;
104
+ }
105
+ //#endregion
106
+ //#region src/types/session.d.ts
107
+ interface Session extends Base {
108
+ /**
109
+ * The device that started the session.
110
+ */
111
+ device: string;
112
+ /**
113
+ * The user who started the session.
114
+ */
115
+ user: string;
116
+ /**
117
+ * The executions of the session.
118
+ */
119
+ executions: Execution<any, any>[];
120
+ }
121
+ //#endregion
122
+ //#region src/types/context.d.ts
123
+ interface SessionContext {
124
+ /**
125
+ * The current working directory.
126
+ */
127
+ cwd: string;
128
+ /**
129
+ * The settings for the context.
130
+ */
131
+ settings: Settings;
132
+ /**
133
+ * The Unstorage storage for the context.
134
+ *
135
+ * @remarks
136
+ * This storage can be used to store the input and output of the execution.
137
+ */
138
+ storage: Storage;
139
+ /**
140
+ * The logger for the context.
141
+ */
142
+ logger: Logger;
143
+ /**
144
+ * The session for the context.
145
+ */
146
+ session: Session;
147
+ }
148
+ interface ExecutionContext<TSpec, TOptions extends object, TReturns = void> extends SessionContext, Execution<TSpec, TOptions> {
149
+ /**
150
+ * The options for the execution.
151
+ */
152
+ options: TOptions;
153
+ /**
154
+ * The specification for the execution.
155
+ */
156
+ get spec(): TSpec;
157
+ /**
158
+ * The schema for the execution.
159
+ */
160
+ get schema(): SchemaOf<TSpec>;
161
+ /**
162
+ * The input for the execution.
163
+ */
164
+ get input(): Input<TSpec, TOptions>;
165
+ /**
166
+ * The output for the execution.
167
+ */
168
+ get output(): Output<TSpec, TOptions, TReturns>;
169
+ /**
170
+ * The documents that are currently being processed, indexed by the document path.
171
+ */
172
+ get documents(): Record<string, ExecutionDocument>;
173
+ /**
174
+ * Adds a document to the currently processing documents.
175
+ *
176
+ * @param pathOrDocument - A string representing the path of the document to add, or the document to add.
177
+ * @param document - The document to add (without the path), if {@link pathOrDocument} is a string representing the document path.
178
+ */
179
+ addDocument: (pathOrDocument: string | ExecutionDocument, document?: Omit<ExecutionDocument, "path">) => void;
180
+ }
181
+ //#endregion
182
+ export { Execution as a, ExecutionMeta as c, Base as i, ExecutionResult as l, SessionContext as n, ExecutionDocument as o, Session as r, ExecutionDocumentChunk as s, ExecutionContext as t };
183
+ //# sourceMappingURL=context-BCW5TgL-.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-BCW5TgL-.d.mts","names":[],"sources":["../src/types/execution.ts","../src/types/base.ts","../src/types/session.ts","../src/types/context.ts"],"mappings":""}
@@ -0,0 +1,183 @@
1
+ import { B as SchemaMetaConfig, H as SchemaOf, M as Input, W as MetaConfig, c as Settings, m as GeneratedDocument, s as Logger, u as Output, x as GeneratorMeta } from "./config-B_E87BPl.cjs";
2
+ import { Storage } from "unstorage";
3
+ //#region src/types/execution.d.ts
4
+ interface ExecutionDocumentChunk {
5
+ /**
6
+ * The content of the chunk.
7
+ */
8
+ content: string;
9
+ /**
10
+ * The metadata of the chunk.
11
+ */
12
+ meta: MetaConfig;
13
+ }
14
+ interface ExecutionDocument {
15
+ /**
16
+ * The path of the document.
17
+ */
18
+ path: string;
19
+ /**
20
+ * The language of the document.
21
+ */
22
+ language?: string;
23
+ /**
24
+ * The chunks of the document.
25
+ */
26
+ chunks: ExecutionDocumentChunk[];
27
+ /**
28
+ * The metadata of the document.
29
+ */
30
+ meta: MetaConfig;
31
+ }
32
+ interface ExecutionMeta<TSpec, TOptions extends object> extends MetaConfig {
33
+ /**
34
+ * A unique identifier for the execution, typically used by the backend systems.
35
+ *
36
+ * @remarks
37
+ * This value will be in the UUID format, which is a 128-bit number represented as a string of hexadecimal digits. It is used to uniquely identify the execution in the backend systems and can be used for tracking and auditing purposes.
38
+ */
39
+ executionId: string;
40
+ /**
41
+ * The date and time when the execution was performed.
42
+ */
43
+ executedAt: Date;
44
+ /**
45
+ * The user who performed the execution.
46
+ */
47
+ executedBy: string;
48
+ /**
49
+ * The specification used to generate the source code during the execution.
50
+ */
51
+ spec: TSpec;
52
+ /**
53
+ * The metadata of the generator used to execute the source code during the execution.
54
+ */
55
+ generator: GeneratorMeta<TSpec, TOptions>;
56
+ /**
57
+ * The metadata of the schema used to generate the source code during the execution.
58
+ */
59
+ schema: SchemaMetaConfig<TSpec>;
60
+ /**
61
+ * The metadata of the input used to generate the source code during the execution.
62
+ */
63
+ input: MetaConfig;
64
+ /**
65
+ * The metadata of the output used to generate the source code during the execution.
66
+ */
67
+ output: MetaConfig;
68
+ }
69
+ interface Execution<TSpec, TOptions extends object> {
70
+ /**
71
+ * The documents of the execution, indexed by the document path.
72
+ */
73
+ documents: Record<string, ExecutionDocument>;
74
+ /**
75
+ * The metadata of the execution.
76
+ */
77
+ meta: ExecutionMeta<TSpec, TOptions>;
78
+ }
79
+ type ExecutionResult<TSpec, TOptions extends object, TReturns = void> = GeneratedDocument<TSpec, TOptions> & {
80
+ /**
81
+ * The returned value of the generator function.
82
+ */
83
+ returns?: TReturns;
84
+ };
85
+ //#endregion
86
+ //#region src/types/base.d.ts
87
+ interface Base {
88
+ /**
89
+ * A unique identifier for the model.
90
+ */
91
+ id: string;
92
+ /**
93
+ * The timestamp when the model was created.
94
+ */
95
+ createdAt: Date;
96
+ /**
97
+ * The timestamp when the model was last updated.
98
+ */
99
+ updatedAt: Date;
100
+ /**
101
+ * The description of the model.
102
+ */
103
+ description?: string;
104
+ }
105
+ //#endregion
106
+ //#region src/types/session.d.ts
107
+ interface Session extends Base {
108
+ /**
109
+ * The device that started the session.
110
+ */
111
+ device: string;
112
+ /**
113
+ * The user who started the session.
114
+ */
115
+ user: string;
116
+ /**
117
+ * The executions of the session.
118
+ */
119
+ executions: Execution<any, any>[];
120
+ }
121
+ //#endregion
122
+ //#region src/types/context.d.ts
123
+ interface SessionContext {
124
+ /**
125
+ * The current working directory.
126
+ */
127
+ cwd: string;
128
+ /**
129
+ * The settings for the context.
130
+ */
131
+ settings: Settings;
132
+ /**
133
+ * The Unstorage storage for the context.
134
+ *
135
+ * @remarks
136
+ * This storage can be used to store the input and output of the execution.
137
+ */
138
+ storage: Storage;
139
+ /**
140
+ * The logger for the context.
141
+ */
142
+ logger: Logger;
143
+ /**
144
+ * The session for the context.
145
+ */
146
+ session: Session;
147
+ }
148
+ interface ExecutionContext<TSpec, TOptions extends object, TReturns = void> extends SessionContext, Execution<TSpec, TOptions> {
149
+ /**
150
+ * The options for the execution.
151
+ */
152
+ options: TOptions;
153
+ /**
154
+ * The specification for the execution.
155
+ */
156
+ get spec(): TSpec;
157
+ /**
158
+ * The schema for the execution.
159
+ */
160
+ get schema(): SchemaOf<TSpec>;
161
+ /**
162
+ * The input for the execution.
163
+ */
164
+ get input(): Input<TSpec, TOptions>;
165
+ /**
166
+ * The output for the execution.
167
+ */
168
+ get output(): Output<TSpec, TOptions, TReturns>;
169
+ /**
170
+ * The documents that are currently being processed, indexed by the document path.
171
+ */
172
+ get documents(): Record<string, ExecutionDocument>;
173
+ /**
174
+ * Adds a document to the currently processing documents.
175
+ *
176
+ * @param pathOrDocument - A string representing the path of the document to add, or the document to add.
177
+ * @param document - The document to add (without the path), if {@link pathOrDocument} is a string representing the document path.
178
+ */
179
+ addDocument: (pathOrDocument: string | ExecutionDocument, document?: Omit<ExecutionDocument, "path">) => void;
180
+ }
181
+ //#endregion
182
+ export { Execution as a, ExecutionMeta as c, Base as i, ExecutionResult as l, SessionContext as n, ExecutionDocument as o, Session as r, ExecutionDocumentChunk as s, ExecutionContext as t };
183
+ //# sourceMappingURL=context-C0n9Tore.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-C0n9Tore.d.cts","names":[],"sources":["../src/types/execution.ts","../src/types/base.ts","../src/types/session.ts","../src/types/context.ts"],"mappings":";;;UAsBiB;;;;EAIf;;;;EAKA,MAAM;;UAGS;;;;EAIf;;;;EAKA;;;;EAKA,QAAQ;;;;EAKR,MAAM;;UAGS,cACf,OACA,iCACQ;;;;;;;EAOR;;;;EAKA,YAAY;;;;EAKZ;;;;EAKA,MAAM;;;;EAKN,WAAW,cAAc,OAAO;;;;EAKhC,QAAQ,iBAAiB;;;;EAKzB,OAAO;;;;EAKP,QAAQ;;UAGO,UAAU,OAAO;;;;EAIhC,WAAW,eAAe;;;;EAK1B,MAAM,cAAc,OAAO;;KAGjB,gBACV,OACA,yBACA,mBACE,kBAAkB,OAAO;;;;EAI3B,UAAU;;;;UC1GK;;;;EAIf;;;;EAKA,WAAW;;;;EAKX,WAAW;;;;EAKX;;;;UChBe,gBAAgB;;;;EAI/B;;;;EAKA;;;;EAKA,YAAY;;;;UCTG;;;;EAIf;;;;EAKA,UAAU;;;;;;;EAQV,SAAS;;;;EAKT,QAAQ;;;;EAKR,SAAS;;UAGM,iBACf,OACA,yBACA,yBAEQ,gBAAgB,UAAU,OAAO;;;;EAIzC,SAAS;;;;MAKL,QAAQ;;;;MAKR,UAAU,SAAS;;;;MAKnB,SAAS,MAAM,OAAO;;;;MAKtB,UAAU,OAAO,OAAO,UAAU;;;;MAKlC,aAAa,eAAe;;;;;;;EAQhC,cACE,yBAAyB,mBACzB,WAAW,KAAK"}
package/dist/context.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@stryke/string-format/snake-case"),t=require("@stryke/string-format/title-case"),n=require("node:async_hooks");const r=globalThis;function i(i){let a=`$$__power_plant_{key}_context__`.replace(`{key}`,(0,e.snakeCase)(i.trim().replace(/^[_-]*/g,``).replace(/[_-]*$/g,``)));return r[a]??(r[a]={asyncLocalStorage:new n.AsyncLocalStorage,use(){let e=this.asyncLocalStorage.getStore();if(e===void 0)throw Error(`The ${(0,t.titleCase)(i.trim().replace(/^[_-]*/g,``).replace(/[_-]*$/g,``))} context is not available. Please ensure that the context has been initialized before using it.`);return e},tryUse(){return this.asyncLocalStorage.getStore()},call(e,t){return this.asyncLocalStorage.run(e,t)},async callAsync(e,t){return this.asyncLocalStorage.run(e,t)}}),r[a]}const a=i(`session`),o=a.asyncLocalStorage,s=a.use,c=a.tryUse,l=a.call,u=a.callAsync,d=i(`execution`),f=d.asyncLocalStorage,p=d.use,m=d.tryUse,h=d.call,g=d.callAsync;exports.callAsyncExecutionContext=g,exports.callAsyncSessionContext=u,exports.callExecutionContext=h,exports.callSessionContext=l,exports.executionAsyncLocalStorage=f,exports.executionContext=d,exports.sessionAsyncLocalStorage=o,exports.sessionContext=a,exports.tryUseExecutionContext=m,exports.tryUseSessionContext=c,exports.useExecutionContext=p,exports.useSessionContext=s;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@stryke/string-format/snake-case"),t=require("@stryke/string-format/title-case"),n=require("node:async_hooks");const r=globalThis;function i(i){let a=`$$__power_plant_{key}_context__`.replace(`{key}`,(0,e.snakeCase)(i.trim().replace(/^[_-]*/g,``).replace(/[_-]*$/g,``)));return r[a]??(r[a]={asyncLocalStorage:new n.AsyncLocalStorage,use(){let e=this.asyncLocalStorage.getStore();if(e===void 0)throw Error(`The ${(0,t.titleCase)(i.trim().replace(/^[_-]*/g,``).replace(/[_-]*$/g,``))} context is not available. Please ensure that the context has been initialized before using it.`);return e},tryUse(){return this.asyncLocalStorage.getStore()},call(e,t){return this.asyncLocalStorage.run(e,t)},async callAsync(e,t){return this.asyncLocalStorage.run(e,t)}}),r[a]}const a=i(`session`),o=a.asyncLocalStorage,s=a.use,c=s,l=a.tryUse,u=l,d=a.call,f=d,p=a.callAsync,m=p,h=i(`execution`),g=h.asyncLocalStorage,_=h.use,v=_,y=h.tryUse,b=y,x=h.call,S=x,C=h.callAsync,w=C;exports.callAsyncExecution=w,exports.callAsyncExecutionContext=C,exports.callAsyncSession=m,exports.callAsyncSessionContext=p,exports.callExecution=S,exports.callExecutionContext=x,exports.callSession=f,exports.callSessionContext=d,exports.executionAsyncLocalStorage=g,exports.executionContext=h,exports.sessionAsyncLocalStorage=o,exports.sessionContext=a,exports.tryUseExecution=b,exports.tryUseExecutionContext=y,exports.tryUseSession=u,exports.tryUseSessionContext=l,exports.useExecution=v,exports.useExecutionContext=_,exports.useSession=c,exports.useSessionContext=s;
@@ -1,4 +1,4 @@
1
- import { n as SessionContext, t as ExecutionContext } from "./context-BxqCoy9z.cjs";
1
+ import { n as SessionContext, t as ExecutionContext } from "./context-C0n9Tore.cjs";
2
2
  import { AsyncLocalStorage } from "node:async_hooks";
3
3
  //#region src/context.d.ts
4
4
  /**
@@ -26,12 +26,20 @@ declare const sessionAsyncLocalStorage: AsyncLocalStorage<SessionContext>;
26
26
  * @throws An error if the session context is not available.
27
27
  */
28
28
  declare const useSessionContext: () => SessionContext;
29
+ /**
30
+ * Alias for {@link useSessionContext}.
31
+ */
32
+ declare const useSession: () => SessionContext;
29
33
  /**
30
34
  * The function to try to use the session context.
31
35
  *
32
36
  * @returns The session context or undefined if the session context is not available.
33
37
  */
34
38
  declare const tryUseSessionContext: () => SessionContext | undefined;
39
+ /**
40
+ * Alias for {@link tryUseSessionContext}.
41
+ */
42
+ declare const tryUseSession: () => SessionContext | undefined;
35
43
  /**
36
44
  * The function to call the session context.
37
45
  *
@@ -40,6 +48,10 @@ declare const tryUseSessionContext: () => SessionContext | undefined;
40
48
  * @returns The result of the callback.
41
49
  */
42
50
  declare const callSessionContext: <R>(instance: SessionContext, callback: () => R) => R;
51
+ /**
52
+ * Alias for {@link callSessionContext}.
53
+ */
54
+ declare const callSession: <R>(instance: SessionContext, callback: () => R) => R;
43
55
  /**
44
56
  * The function to call the session context asynchronously.
45
57
  *
@@ -48,6 +60,10 @@ declare const callSessionContext: <R>(instance: SessionContext, callback: () =>
48
60
  * @returns The result of the callback.
49
61
  */
50
62
  declare const callAsyncSessionContext: <R>(instance: SessionContext, callback: () => R | Promise<R>) => Promise<R>;
63
+ /**
64
+ * Alias for {@link callAsyncSessionContext}.
65
+ */
66
+ declare const callAsyncSession: <R>(instance: SessionContext, callback: () => R | Promise<R>) => Promise<R>;
51
67
  /**
52
68
  * The context store for the execution context. This is used to store the execution context for a specific execution.
53
69
  */
@@ -63,12 +79,20 @@ declare const executionAsyncLocalStorage: AsyncLocalStorage<ExecutionContext<any
63
79
  * @throws An error if the execution context is not available.
64
80
  */
65
81
  declare const useExecutionContext: () => ExecutionContext<any, any, any>;
82
+ /**
83
+ * Alias for {@link useExecutionContext}.
84
+ */
85
+ declare const useExecution: () => ExecutionContext<any, any, any>;
66
86
  /**
67
87
  * The function to try to use the execution context.
68
88
  *
69
89
  * @returns The execution context or undefined if the execution context is not available.
70
90
  */
71
91
  declare const tryUseExecutionContext: () => ExecutionContext<any, any, any> | undefined;
92
+ /**
93
+ * Alias for {@link tryUseExecutionContext}.
94
+ */
95
+ declare const tryUseExecution: () => ExecutionContext<any, any, any> | undefined;
72
96
  /**
73
97
  * The function to call the execution context.
74
98
  *
@@ -77,6 +101,10 @@ declare const tryUseExecutionContext: () => ExecutionContext<any, any, any> | un
77
101
  * @returns The result of the callback.
78
102
  */
79
103
  declare const callExecutionContext: <R>(instance: ExecutionContext<any, any, any>, callback: () => R) => R;
104
+ /**
105
+ * Alias for {@link callExecutionContext}.
106
+ */
107
+ declare const callExecution: <R>(instance: ExecutionContext<any, any, any>, callback: () => R) => R;
80
108
  /**
81
109
  * The function to call the execution context asynchronously.
82
110
  *
@@ -85,6 +113,10 @@ declare const callExecutionContext: <R>(instance: ExecutionContext<any, any, any
85
113
  * @returns The result of the callback.
86
114
  */
87
115
  declare const callAsyncExecutionContext: <R>(instance: ExecutionContext<any, any, any>, callback: () => R | Promise<R>) => Promise<R>;
116
+ /**
117
+ * Alias for {@link callAsyncExecutionContext}.
118
+ */
119
+ declare const callAsyncExecution: <R>(instance: ExecutionContext<any, any, any>, callback: () => R | Promise<R>) => Promise<R>;
88
120
  //#endregion
89
- export { ContextStore, callAsyncExecutionContext, callAsyncSessionContext, callExecutionContext, callSessionContext, executionAsyncLocalStorage, executionContext, sessionAsyncLocalStorage, sessionContext, tryUseExecutionContext, tryUseSessionContext, useExecutionContext, useSessionContext };
121
+ export { ContextStore, callAsyncExecution, callAsyncExecutionContext, callAsyncSession, callAsyncSessionContext, callExecution, callExecutionContext, callSession, callSessionContext, executionAsyncLocalStorage, executionContext, sessionAsyncLocalStorage, sessionContext, tryUseExecution, tryUseExecutionContext, tryUseSession, tryUseSessionContext, useExecution, useExecutionContext, useSession, useSessionContext };
90
122
  //# sourceMappingURL=context.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.cts","names":[],"sources":["../src/context.ts"],"mappings":";;;;;;UA0BiB,aAAa,iBAAiB;EAC7C,mBAAmB,kBAAkB;EACrC,WAAW;EACX,cAAc;EACd,OAAO,GAAG,UAAU,UAAU,gBAAgB,MAAM;EACpD,YAAY,GACV,UAAU,UACV,gBAAgB,IAAI,QAAQ,OACzB,QAAQ;;;;;cAyDF,gBAAc,aAAA;;;;cAKd,0BAAwB,kBAAA;;;;;;;cAQxB,yBAAiB;;;;;;cAOjB,4BAAoB;;;;;;;;cASpB,qBA1FJ,GAAC,UAAA,gBAAA,gBAAA,MAAA;;;;;;;;cAmGG,0BAlGC,GAAC,UAAA,gBAAA,gBAAA,IAAA,QAAA,OAAA,QAAA;;;;cAuGF,kBAAgB,aAAA;;;;cAMhB,4BAA0B,kBAAA;;;;;;;cAQ1B,2BAAmB;;;;;;cAOnB,8BAAsB;;;;;;;;cAStB,uBAtIJ,GAAC,UAAA,iCAAA,gBAAA,MAAA;;;;;;;;cA+IG,4BA9IC,GAAC,UAAA,iCAAA,gBAAA,IAAA,QAAA,OAAA,QAAA"}
1
+ {"version":3,"file":"context.d.cts","names":[],"sources":["../src/context.ts"],"mappings":";;;;;;UA0BiB,aAAa,iBAAiB;EAC7C,mBAAmB,kBAAkB;EACrC,WAAW;EACX,cAAc;EACd,OAAO,GAAG,UAAU,UAAU,gBAAgB,MAAM;EACpD,YAAY,GACV,UAAU,UACV,gBAAgB,IAAI,QAAQ,OACzB,QAAQ;;;;;cAyDF,gBAAc,aAAA;;;;cAKd,0BAAwB,kBAAA;;;;;;;cAQxB,yBAAiB;;;;cAKjB,kBAAU;;;;;;cAOV,4BAAoB;;;;cAKpB,qBAAa;;;;;;;;cASb,qBApGJ,GAAC,UAAA,gBAAA,gBAAA,MAAA;;;;cAyGG,cAzGJ,GAAC,UAAA,gBAAA,gBAAA,MAAA;;;;;;;;cAkHG,0BAjHC,GAAC,UAAA,gBAAA,gBAAA,IAAA,QAAA,OAAA,QAAA;;;;cAsHF,mBAtHC,GAAC,UAAA,gBAAA,gBAAA,IAAA,QAAA,OAAA,QAAA;;;;cA2HF,kBAAgB,aAAA;;;;cAMhB,4BAA0B,kBAAA;;;;;;;cAQ1B,2BAAmB;;;;cAKnB,oBAAY;;;;;;cAOZ,8BAAsB;;;;cAKtB,uBAAe;;;;;;;;cASf,uBApKJ,GAAC,UAAA,iCAAA,gBAAA,MAAA;;;;cAyKG,gBAzKJ,GAAC,UAAA,iCAAA,gBAAA,MAAA;;;;;;;;cAkLG,4BAjLC,GAAC,UAAA,iCAAA,gBAAA,IAAA,QAAA,OAAA,QAAA;;;;cAsLF,qBAtLC,GAAC,UAAA,iCAAA,gBAAA,IAAA,QAAA,OAAA,QAAA"}
@@ -1,4 +1,4 @@
1
- import { n as SessionContext, t as ExecutionContext } from "./context-COQtFcI5.mjs";
1
+ import { n as SessionContext, t as ExecutionContext } from "./context-BCW5TgL-.mjs";
2
2
  import { AsyncLocalStorage } from "node:async_hooks";
3
3
  //#region src/context.d.ts
4
4
  /**
@@ -26,12 +26,20 @@ declare const sessionAsyncLocalStorage: AsyncLocalStorage<SessionContext>;
26
26
  * @throws An error if the session context is not available.
27
27
  */
28
28
  declare const useSessionContext: () => SessionContext;
29
+ /**
30
+ * Alias for {@link useSessionContext}.
31
+ */
32
+ declare const useSession: () => SessionContext;
29
33
  /**
30
34
  * The function to try to use the session context.
31
35
  *
32
36
  * @returns The session context or undefined if the session context is not available.
33
37
  */
34
38
  declare const tryUseSessionContext: () => SessionContext | undefined;
39
+ /**
40
+ * Alias for {@link tryUseSessionContext}.
41
+ */
42
+ declare const tryUseSession: () => SessionContext | undefined;
35
43
  /**
36
44
  * The function to call the session context.
37
45
  *
@@ -40,6 +48,10 @@ declare const tryUseSessionContext: () => SessionContext | undefined;
40
48
  * @returns The result of the callback.
41
49
  */
42
50
  declare const callSessionContext: <R>(instance: SessionContext, callback: () => R) => R;
51
+ /**
52
+ * Alias for {@link callSessionContext}.
53
+ */
54
+ declare const callSession: <R>(instance: SessionContext, callback: () => R) => R;
43
55
  /**
44
56
  * The function to call the session context asynchronously.
45
57
  *
@@ -48,6 +60,10 @@ declare const callSessionContext: <R>(instance: SessionContext, callback: () =>
48
60
  * @returns The result of the callback.
49
61
  */
50
62
  declare const callAsyncSessionContext: <R>(instance: SessionContext, callback: () => R | Promise<R>) => Promise<R>;
63
+ /**
64
+ * Alias for {@link callAsyncSessionContext}.
65
+ */
66
+ declare const callAsyncSession: <R>(instance: SessionContext, callback: () => R | Promise<R>) => Promise<R>;
51
67
  /**
52
68
  * The context store for the execution context. This is used to store the execution context for a specific execution.
53
69
  */
@@ -63,12 +79,20 @@ declare const executionAsyncLocalStorage: AsyncLocalStorage<ExecutionContext<any
63
79
  * @throws An error if the execution context is not available.
64
80
  */
65
81
  declare const useExecutionContext: () => ExecutionContext<any, any, any>;
82
+ /**
83
+ * Alias for {@link useExecutionContext}.
84
+ */
85
+ declare const useExecution: () => ExecutionContext<any, any, any>;
66
86
  /**
67
87
  * The function to try to use the execution context.
68
88
  *
69
89
  * @returns The execution context or undefined if the execution context is not available.
70
90
  */
71
91
  declare const tryUseExecutionContext: () => ExecutionContext<any, any, any> | undefined;
92
+ /**
93
+ * Alias for {@link tryUseExecutionContext}.
94
+ */
95
+ declare const tryUseExecution: () => ExecutionContext<any, any, any> | undefined;
72
96
  /**
73
97
  * The function to call the execution context.
74
98
  *
@@ -77,6 +101,10 @@ declare const tryUseExecutionContext: () => ExecutionContext<any, any, any> | un
77
101
  * @returns The result of the callback.
78
102
  */
79
103
  declare const callExecutionContext: <R>(instance: ExecutionContext<any, any, any>, callback: () => R) => R;
104
+ /**
105
+ * Alias for {@link callExecutionContext}.
106
+ */
107
+ declare const callExecution: <R>(instance: ExecutionContext<any, any, any>, callback: () => R) => R;
80
108
  /**
81
109
  * The function to call the execution context asynchronously.
82
110
  *
@@ -85,6 +113,10 @@ declare const callExecutionContext: <R>(instance: ExecutionContext<any, any, any
85
113
  * @returns The result of the callback.
86
114
  */
87
115
  declare const callAsyncExecutionContext: <R>(instance: ExecutionContext<any, any, any>, callback: () => R | Promise<R>) => Promise<R>;
116
+ /**
117
+ * Alias for {@link callAsyncExecutionContext}.
118
+ */
119
+ declare const callAsyncExecution: <R>(instance: ExecutionContext<any, any, any>, callback: () => R | Promise<R>) => Promise<R>;
88
120
  //#endregion
89
- export { ContextStore, callAsyncExecutionContext, callAsyncSessionContext, callExecutionContext, callSessionContext, executionAsyncLocalStorage, executionContext, sessionAsyncLocalStorage, sessionContext, tryUseExecutionContext, tryUseSessionContext, useExecutionContext, useSessionContext };
121
+ export { ContextStore, callAsyncExecution, callAsyncExecutionContext, callAsyncSession, callAsyncSessionContext, callExecution, callExecutionContext, callSession, callSessionContext, executionAsyncLocalStorage, executionContext, sessionAsyncLocalStorage, sessionContext, tryUseExecution, tryUseExecutionContext, tryUseSession, tryUseSessionContext, useExecution, useExecutionContext, useSession, useSessionContext };
90
122
  //# sourceMappingURL=context.d.mts.map
package/dist/context.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{snakeCase as e}from"@stryke/string-format/snake-case";import{titleCase as t}from"@stryke/string-format/title-case";import{AsyncLocalStorage as n}from"node:async_hooks";const r=globalThis;function i(i){let a=`$$__power_plant_{key}_context__`.replace(`{key}`,e(i.trim().replace(/^[_-]*/g,``).replace(/[_-]*$/g,``)));return r[a]??(r[a]={asyncLocalStorage:new n,use(){let e=this.asyncLocalStorage.getStore();if(e===void 0)throw Error(`The ${t(i.trim().replace(/^[_-]*/g,``).replace(/[_-]*$/g,``))} context is not available. Please ensure that the context has been initialized before using it.`);return e},tryUse(){return this.asyncLocalStorage.getStore()},call(e,t){return this.asyncLocalStorage.run(e,t)},async callAsync(e,t){return this.asyncLocalStorage.run(e,t)}}),r[a]}const a=i(`session`),o=a.asyncLocalStorage,s=a.use,c=a.tryUse,l=a.call,u=a.callAsync,d=i(`execution`),f=d.asyncLocalStorage,p=d.use,m=d.tryUse,h=d.call,g=d.callAsync;export{g as callAsyncExecutionContext,u as callAsyncSessionContext,h as callExecutionContext,l as callSessionContext,f as executionAsyncLocalStorage,d as executionContext,o as sessionAsyncLocalStorage,a as sessionContext,m as tryUseExecutionContext,c as tryUseSessionContext,p as useExecutionContext,s as useSessionContext};
1
+ import{snakeCase as e}from"@stryke/string-format/snake-case";import{titleCase as t}from"@stryke/string-format/title-case";import{AsyncLocalStorage as n}from"node:async_hooks";const r=globalThis;function i(i){let a=`$$__power_plant_{key}_context__`.replace(`{key}`,e(i.trim().replace(/^[_-]*/g,``).replace(/[_-]*$/g,``)));return r[a]??(r[a]={asyncLocalStorage:new n,use(){let e=this.asyncLocalStorage.getStore();if(e===void 0)throw Error(`The ${t(i.trim().replace(/^[_-]*/g,``).replace(/[_-]*$/g,``))} context is not available. Please ensure that the context has been initialized before using it.`);return e},tryUse(){return this.asyncLocalStorage.getStore()},call(e,t){return this.asyncLocalStorage.run(e,t)},async callAsync(e,t){return this.asyncLocalStorage.run(e,t)}}),r[a]}const a=i(`session`),o=a.asyncLocalStorage,s=a.use,c=s,l=a.tryUse,u=l,d=a.call,f=d,p=a.callAsync,m=p,h=i(`execution`),g=h.asyncLocalStorage,_=h.use,v=_,y=h.tryUse,b=y,x=h.call,S=x,C=h.callAsync,w=C;export{w as callAsyncExecution,C as callAsyncExecutionContext,m as callAsyncSession,p as callAsyncSessionContext,S as callExecution,x as callExecutionContext,f as callSession,d as callSessionContext,g as executionAsyncLocalStorage,h as executionContext,o as sessionAsyncLocalStorage,a as sessionContext,b as tryUseExecution,y as tryUseExecutionContext,u as tryUseSession,l as tryUseSessionContext,v as useExecution,_ as useExecutionContext,c as useSession,s as useSessionContext};
2
2
  //# sourceMappingURL=context.mjs.map
package/dist/define.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { F as InputConfig, H as SchemaConfigObject, I as InputConfigObject, d as OutputConfig, f as OutputConfigObject, y as GeneratorConfigObject } from "./config-DMItzxbk.cjs";
1
+ import { N as InputConfig, P as InputConfigObject, d as OutputConfig, f as OutputConfigObject, v as GeneratorConfigObject, z as SchemaConfigObject } from "./config-B_E87BPl.cjs";
2
2
  import { SchemaEnvelopeOf, SchemaSourceConfig } from "@power-plant/schema";
3
3
  //#region src/define.d.ts
4
4
  /**
@@ -68,7 +68,7 @@ declare function defineOutput<TSpec, TOptions extends object, TReturns = void>(o
68
68
  * @param schema - The schema configuration to define. This can be either a schema source configuration, a schema envelope, or a schema configuration object.
69
69
  * @returns A schema configuration object that contains the provided schema. If the input was already a schema configuration object, it will be returned unchanged.
70
70
  */
71
- declare function defineSchema<TSpec, TOptions extends object>(schema: SchemaSourceConfig<TSpec> | SchemaEnvelopeOf<TSpec> | SchemaConfigObject<TSpec, TOptions>): SchemaConfigObject<TSpec, TOptions>;
71
+ declare function defineSchema<TSpec>(schema: SchemaSourceConfig<TSpec> | SchemaEnvelopeOf<TSpec> | SchemaConfigObject<TSpec>): SchemaConfigObject<TSpec>;
72
72
  /**
73
73
  * Defines a schema configuration object. If the provided schema is already a schema configuration object, it will be returned as-is. Otherwise, it will be wrapped in an object with a `schema` property.
74
74
  *
@@ -1 +1 @@
1
- {"version":3,"file":"define.d.cts","names":[],"sources":["../src/define.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6DgB,YAAY,OAAO,yBACjC,OAAO,YAAY,OAAO,YACzB,kBAAkB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoCZ,aAAa,OAAO,yBAAyB,iBAC3D,QAAQ,aAAa,OAAO,UAAU,YACrC,mBAAmB,OAAO,UAAU;;;;;;;iBAcvB,aAAa,OAAO,yBAClC,QACI,mBAAmB,SACnB,iBAAiB,SACjB,mBAAmB,OAAO,YAC7B,mBAAmB,OAAO;;;;;;;iBAcb,gBACd,OACA,yBACA,iBAEA,WAAW,sBAAsB,OAAO,UAAU,YACjD,sBAAsB,OAAO,UAAU"}
1
+ {"version":3,"file":"define.d.cts","names":[],"sources":["../src/define.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6DgB,YAAY,OAAO,yBACjC,OAAO,YAAY,OAAO,YACzB,kBAAkB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoCZ,aAAa,OAAO,yBAAyB,iBAC3D,QAAQ,aAAa,OAAO,UAAU,YACrC,mBAAmB,OAAO,UAAU;;;;;;;iBAcvB,aAAa,OAC3B,QACI,mBAAmB,SACnB,iBAAiB,SACjB,mBAAmB,SACtB,mBAAmB;;;;;;;iBAcN,gBACd,OACA,yBACA,iBAEA,WAAW,sBAAsB,OAAO,UAAU,YACjD,sBAAsB,OAAO,UAAU"}
package/dist/define.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { F as InputConfig, H as SchemaConfigObject, I as InputConfigObject, d as OutputConfig, f as OutputConfigObject, y as GeneratorConfigObject } from "./config-DMItzxbk.mjs";
1
+ import { N as InputConfig, P as InputConfigObject, d as OutputConfig, f as OutputConfigObject, v as GeneratorConfigObject, z as SchemaConfigObject } from "./config-B_E87BPl.mjs";
2
2
  import { SchemaEnvelopeOf, SchemaSourceConfig } from "@power-plant/schema";
3
3
  //#region src/define.d.ts
4
4
  /**
@@ -68,7 +68,7 @@ declare function defineOutput<TSpec, TOptions extends object, TReturns = void>(o
68
68
  * @param schema - The schema configuration to define. This can be either a schema source configuration, a schema envelope, or a schema configuration object.
69
69
  * @returns A schema configuration object that contains the provided schema. If the input was already a schema configuration object, it will be returned unchanged.
70
70
  */
71
- declare function defineSchema<TSpec, TOptions extends object>(schema: SchemaSourceConfig<TSpec> | SchemaEnvelopeOf<TSpec> | SchemaConfigObject<TSpec, TOptions>): SchemaConfigObject<TSpec, TOptions>;
71
+ declare function defineSchema<TSpec>(schema: SchemaSourceConfig<TSpec> | SchemaEnvelopeOf<TSpec> | SchemaConfigObject<TSpec>): SchemaConfigObject<TSpec>;
72
72
  /**
73
73
  * Defines a schema configuration object. If the provided schema is already a schema configuration object, it will be returned as-is. Otherwise, it will be wrapped in an object with a `schema` property.
74
74
  *
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./type-checks.cjs"),t=require("./config.cjs"),n=require("./context.cjs"),r=require("./define.cjs");exports.callAsyncExecutionContext=n.callAsyncExecutionContext,exports.callAsyncSessionContext=n.callAsyncSessionContext,exports.callExecutionContext=n.callExecutionContext,exports.callSessionContext=n.callSessionContext,exports.defineConfig=t.defineConfig,exports.defineGenerator=r.defineGenerator,exports.defineInput=r.defineInput,exports.defineOutput=r.defineOutput,exports.defineSchema=r.defineSchema,exports.executionAsyncLocalStorage=n.executionAsyncLocalStorage,exports.executionContext=n.executionContext,exports.isGeneratorConfigObject=e.isGeneratorConfigObject,exports.isInputConfigObject=e.isInputConfigObject,exports.isOutputConfigObject=e.isOutputConfigObject,exports.isSchemaConfigObject=e.isSchemaConfigObject,exports.sessionAsyncLocalStorage=n.sessionAsyncLocalStorage,exports.sessionContext=n.sessionContext,exports.tryUseExecutionContext=n.tryUseExecutionContext,exports.tryUseSessionContext=n.tryUseSessionContext,exports.useExecutionContext=n.useExecutionContext,exports.useSessionContext=n.useSessionContext;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./type-checks.cjs"),t=require("./config.cjs"),n=require("./context.cjs"),r=require("./define.cjs");exports.callAsyncExecution=n.callAsyncExecution,exports.callAsyncExecutionContext=n.callAsyncExecutionContext,exports.callAsyncSession=n.callAsyncSession,exports.callAsyncSessionContext=n.callAsyncSessionContext,exports.callExecution=n.callExecution,exports.callExecutionContext=n.callExecutionContext,exports.callSession=n.callSession,exports.callSessionContext=n.callSessionContext,exports.defineConfig=t.defineConfig,exports.defineGenerator=r.defineGenerator,exports.defineInput=r.defineInput,exports.defineOutput=r.defineOutput,exports.defineSchema=r.defineSchema,exports.executionAsyncLocalStorage=n.executionAsyncLocalStorage,exports.executionContext=n.executionContext,exports.isGeneratorConfigObject=e.isGeneratorConfigObject,exports.isInputConfigObject=e.isInputConfigObject,exports.isOutputConfigObject=e.isOutputConfigObject,exports.isSchemaConfigObject=e.isSchemaConfigObject,exports.sessionAsyncLocalStorage=n.sessionAsyncLocalStorage,exports.sessionContext=n.sessionContext,exports.tryUseExecution=n.tryUseExecution,exports.tryUseExecutionContext=n.tryUseExecutionContext,exports.tryUseSession=n.tryUseSession,exports.tryUseSessionContext=n.tryUseSessionContext,exports.useExecution=n.useExecution,exports.useExecutionContext=n.useExecutionContext,exports.useSession=n.useSession,exports.useSessionContext=n.useSessionContext;