@power-plant/core 0.0.5 → 0.0.6

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 (135) hide show
  1. package/README.md +2 -2
  2. package/dist/config-B6Gr29ZK.d.cts +566 -0
  3. package/dist/config-B6Gr29ZK.d.cts.map +1 -0
  4. package/dist/config-B6Gr29ZK.d.mts +566 -0
  5. package/dist/config-B6Gr29ZK.d.mts.map +1 -0
  6. package/dist/config.cjs +1 -0
  7. package/dist/config.d.cts +34 -0
  8. package/dist/config.d.cts.map +1 -0
  9. package/dist/config.d.mts +34 -0
  10. package/dist/config.d.mts.map +1 -0
  11. package/dist/config.mjs +2 -0
  12. package/dist/config.mjs.map +1 -0
  13. package/dist/context-QCvV8cA9.d.cts +129 -0
  14. package/dist/context-QCvV8cA9.d.cts.map +1 -0
  15. package/dist/context-neyaFruu.d.mts +129 -0
  16. package/dist/context-neyaFruu.d.mts.map +1 -0
  17. package/dist/context.cjs +1 -0
  18. package/dist/context.d.cts +91 -0
  19. package/dist/context.d.cts.map +1 -0
  20. package/dist/context.d.mts +91 -0
  21. package/dist/context.d.mts.map +1 -0
  22. package/dist/context.mjs +2 -0
  23. package/dist/context.mjs.map +1 -0
  24. package/dist/define.cjs +1 -0
  25. package/dist/define.d.cts +82 -0
  26. package/dist/define.d.cts.map +1 -0
  27. package/dist/define.d.mts +82 -0
  28. package/dist/define.d.mts.map +1 -0
  29. package/dist/define.mjs +2 -0
  30. package/dist/define.mjs.map +1 -0
  31. package/dist/index.cjs +1 -1
  32. package/dist/index.d.cts +7 -101
  33. package/dist/index.d.mts +7 -101
  34. package/dist/index.mjs +1 -1
  35. package/dist/type-checks-C3obf_M5.d.cts +53 -0
  36. package/dist/type-checks-C3obf_M5.d.cts.map +1 -0
  37. package/dist/type-checks-Cj1slvLD.d.mts +53 -0
  38. package/dist/type-checks-Cj1slvLD.d.mts.map +1 -0
  39. package/dist/type-checks.cjs +1 -0
  40. package/dist/type-checks.d.cts +2 -0
  41. package/dist/type-checks.d.mts +2 -0
  42. package/dist/type-checks.mjs +2 -0
  43. package/dist/type-checks.mjs.map +1 -0
  44. package/dist/types/__internal.cjs +0 -0
  45. package/dist/types/__internal.d.cts +14 -0
  46. package/dist/types/__internal.d.cts.map +1 -0
  47. package/dist/types/__internal.d.mts +14 -0
  48. package/dist/types/__internal.d.mts.map +1 -0
  49. package/dist/types/__internal.mjs +1 -0
  50. package/package.json +52 -53
  51. package/dist/context-BGSa-2fY.mjs +0 -2
  52. package/dist/context-BGSa-2fY.mjs.map +0 -1
  53. package/dist/context-Bcrz4kGb.cjs +0 -1
  54. package/dist/create-0IEoomGw.cjs +0 -1
  55. package/dist/create-CYRTmdJO.mjs +0 -2
  56. package/dist/create-CYRTmdJO.mjs.map +0 -1
  57. package/dist/create-D_u2Zj81.cjs +0 -1
  58. package/dist/create-DcfhZUHw.mjs +0 -2
  59. package/dist/create-DcfhZUHw.mjs.map +0 -1
  60. package/dist/create-MFKW4s0V.cjs +0 -1
  61. package/dist/create-cqJljXdZ.mjs +0 -2
  62. package/dist/create-cqJljXdZ.mjs.map +0 -1
  63. package/dist/define-B5baoppv.d.cts +0 -14
  64. package/dist/define-B5baoppv.d.cts.map +0 -1
  65. package/dist/define-BNsSORkE.d.cts +0 -13
  66. package/dist/define-BNsSORkE.d.cts.map +0 -1
  67. package/dist/define-B__DotaM.cjs +0 -1
  68. package/dist/define-BpCv3wD0.d.mts +0 -38
  69. package/dist/define-BpCv3wD0.d.mts.map +0 -1
  70. package/dist/define-Bviec8Ry.d.cts +0 -38
  71. package/dist/define-Bviec8Ry.d.cts.map +0 -1
  72. package/dist/define-C5_Sx-Eg.mjs +0 -2
  73. package/dist/define-C5_Sx-Eg.mjs.map +0 -1
  74. package/dist/define-C_GLY1-q.cjs +0 -1
  75. package/dist/define-Cjl-0yK0.d.mts +0 -13
  76. package/dist/define-Cjl-0yK0.d.mts.map +0 -1
  77. package/dist/define-DE0RBdIR.mjs +0 -2
  78. package/dist/define-DE0RBdIR.mjs.map +0 -1
  79. package/dist/define-DQQxZK9L.d.mts +0 -14
  80. package/dist/define-DQQxZK9L.d.mts.map +0 -1
  81. package/dist/define-DVggP_03.cjs +0 -1
  82. package/dist/define-DY1s6sGY.mjs +0 -2
  83. package/dist/define-DY1s6sGY.mjs.map +0 -1
  84. package/dist/define-OeGEPyv1.d.cts +0 -45
  85. package/dist/define-OeGEPyv1.d.cts.map +0 -1
  86. package/dist/define-hhs2D0Hq.d.mts +0 -45
  87. package/dist/define-hhs2D0Hq.d.mts.map +0 -1
  88. package/dist/generator/index.cjs +0 -1
  89. package/dist/generator/index.d.cts +0 -29
  90. package/dist/generator/index.d.cts.map +0 -1
  91. package/dist/generator/index.d.mts +0 -29
  92. package/dist/generator/index.d.mts.map +0 -1
  93. package/dist/generator/index.mjs +0 -2
  94. package/dist/generator/index.mjs.map +0 -1
  95. package/dist/generator-9GSAWmOj.d.mts +0 -126
  96. package/dist/generator-9GSAWmOj.d.mts.map +0 -1
  97. package/dist/generator-D9KikId4.d.cts +0 -126
  98. package/dist/generator-D9KikId4.d.cts.map +0 -1
  99. package/dist/helpers-8tc33xyp.mjs +0 -2
  100. package/dist/helpers-8tc33xyp.mjs.map +0 -1
  101. package/dist/helpers-BWqqSR02.cjs +0 -1
  102. package/dist/helpers-BcTg0l_X.cjs +0 -1
  103. package/dist/helpers-Botqc1jf.cjs +0 -1
  104. package/dist/helpers-Cfl4NsE5.mjs +0 -2
  105. package/dist/helpers-Cfl4NsE5.mjs.map +0 -1
  106. package/dist/helpers-DwNCh4F3.mjs +0 -2
  107. package/dist/helpers-DwNCh4F3.mjs.map +0 -1
  108. package/dist/index.d.cts.map +0 -1
  109. package/dist/index.d.mts.map +0 -1
  110. package/dist/input/index.cjs +0 -1
  111. package/dist/input/index.d.cts +0 -35
  112. package/dist/input/index.d.cts.map +0 -1
  113. package/dist/input/index.d.mts +0 -35
  114. package/dist/input/index.d.mts.map +0 -1
  115. package/dist/input/index.mjs +0 -1
  116. package/dist/input-C3yGEfI-.d.mts +0 -58
  117. package/dist/input-C3yGEfI-.d.mts.map +0 -1
  118. package/dist/input-Osyk3YIo.d.cts +0 -58
  119. package/dist/input-Osyk3YIo.d.cts.map +0 -1
  120. package/dist/output/index.cjs +0 -1
  121. package/dist/output/index.d.cts +0 -35
  122. package/dist/output/index.d.cts.map +0 -1
  123. package/dist/output/index.d.mts +0 -35
  124. package/dist/output/index.d.mts.map +0 -1
  125. package/dist/output/index.mjs +0 -1
  126. package/dist/schema/index.cjs +0 -1
  127. package/dist/schema/index.d.cts +0 -33
  128. package/dist/schema/index.d.cts.map +0 -1
  129. package/dist/schema/index.d.mts +0 -33
  130. package/dist/schema/index.d.mts.map +0 -1
  131. package/dist/schema/index.mjs +0 -1
  132. package/dist/schema-DvnNqFd4.d.cts +0 -180
  133. package/dist/schema-DvnNqFd4.d.cts.map +0 -1
  134. package/dist/schema-DvnNqFd4.d.mts +0 -180
  135. package/dist/schema-DvnNqFd4.d.mts.map +0 -1
@@ -0,0 +1,129 @@
1
+ import { A as ExtractedExecution, E as ExecutionDocument, K as SchemaOf, P as Input, T as Execution, c as Settings, s as Logger, u as Output } from "./config-B6Gr29ZK.cjs";
2
+ import { Storage } from "unstorage";
3
+
4
+ //#region src/types/session.d.ts
5
+ interface SessionUserInfo {
6
+ /**
7
+ * The user name for the active session.
8
+ */
9
+ name: string;
10
+ /**
11
+ * The display name for the active user.
12
+ */
13
+ displayName: string;
14
+ /**
15
+ * The user's language preferences.
16
+ */
17
+ languagePreferences: string[];
18
+ }
19
+ interface SessionDeviceInfo {
20
+ /**
21
+ * The device name for the active session.
22
+ */
23
+ name: string;
24
+ /**
25
+ * The display name for the active device.
26
+ */
27
+ displayName: string;
28
+ /**
29
+ * The platform identifier for the active device.
30
+ */
31
+ platform: string;
32
+ /**
33
+ * The OS distribution for the active device.
34
+ */
35
+ distro: string;
36
+ /**
37
+ * The desktop environment for the active device.
38
+ */
39
+ desktopEnv: string;
40
+ /**
41
+ * The CPU architecture for the active device.
42
+ */
43
+ cpuArch: string;
44
+ }
45
+ interface Session {
46
+ /**
47
+ * A unique identifier for the session.
48
+ */
49
+ sessionId: string;
50
+ /**
51
+ * The timestamp indicating when the session started.
52
+ */
53
+ startedAt: Date;
54
+ /**
55
+ * Information about the current user.
56
+ */
57
+ user: SessionUserInfo;
58
+ /**
59
+ * Information about the current device.
60
+ */
61
+ device: SessionDeviceInfo;
62
+ }
63
+ //#endregion
64
+ //#region src/types/context.d.ts
65
+ interface SessionContext {
66
+ /**
67
+ * The current working directory.
68
+ */
69
+ cwd: string;
70
+ /**
71
+ * The settings for the context.
72
+ */
73
+ settings: Settings;
74
+ /**
75
+ * The Unstorage storage for the context.
76
+ *
77
+ * @remarks
78
+ * This storage can be used to store the input and output of the execution.
79
+ */
80
+ storage: Storage;
81
+ /**
82
+ * The logger for the context.
83
+ */
84
+ logger: Logger;
85
+ /**
86
+ * The session for the context.
87
+ */
88
+ session: Session;
89
+ /**
90
+ * The executions that have been performed in the context.
91
+ */
92
+ executions: ExtractedExecution<any, any>[];
93
+ }
94
+ interface ExecutionContext<TSpec, TOptions extends object, TReturns = void> extends SessionContext, Execution<TSpec, TOptions> {
95
+ /**
96
+ * The options for the execution.
97
+ */
98
+ options: TOptions;
99
+ /**
100
+ * The specification for the execution.
101
+ */
102
+ get spec(): TSpec;
103
+ /**
104
+ * The schema for the execution.
105
+ */
106
+ get schema(): SchemaOf<TSpec, TOptions>;
107
+ /**
108
+ * The input for the execution.
109
+ */
110
+ get input(): Input<TSpec, TOptions>;
111
+ /**
112
+ * The output for the execution.
113
+ */
114
+ get output(): Output<TSpec, TOptions, TReturns>;
115
+ /**
116
+ * The documents that are currently being processed, indexed by the document path.
117
+ */
118
+ get documents(): Record<string, ExecutionDocument<TSpec, TOptions>>;
119
+ /**
120
+ * Adds a document to the currently processing documents.
121
+ *
122
+ * @param pathOrDocument - A string representing the path of the document to add, or the document to add.
123
+ * @param document - The document to add (without the path), if {@link pathOrDocument} is a string representing the document path.
124
+ */
125
+ addDocument: (pathOrDocument: string | ExecutionDocument<TSpec, TOptions>, document?: Omit<ExecutionDocument<TSpec, TOptions>, "path">) => void;
126
+ }
127
+ //#endregion
128
+ export { SessionUserInfo as a, SessionDeviceInfo as i, SessionContext as n, Session as r, ExecutionContext as t };
129
+ //# sourceMappingURL=context-QCvV8cA9.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-QCvV8cA9.d.cts","names":[],"sources":["../src/types/session.ts","../src/types/context.ts"],"mappings":";;;;UAkBiB,eAAA;;;;EAIf,IAAA;EAJ8B;;;EAS9B,WAAA;EAAA;;;EAKA,mBAAA;AAAA;AAAA,UAGe,iBAAA;;;;EAIf,IAAA;EAUA;;;EALA,WAAA;EAoBO;AAAA;AAGT;EAlBE,QAAA;;;;EAKA,MAAA;EAgCyB;;;EA3BzB,UAAA;EAiBW;;;EAZX,OAAA;AAAA;AAAA,UAGe,OAAA;EAmBU;;;EAfzB,SAAA;ECzCe;;;ED8Cf,SAAA,EAAW,IAAA;EC7BF;;;EDkCT,IAAA,EAAM,eAAA;ECnBwB;;;EDwB9B,MAAA,EAAQ,iBAAA;AAAA;;;UCxDO,cAAA;EDRf;;;ECYA,GAAA;EDFmB;AAGrB;;ECIE,QAAA,EAAU,QAAA;EDJsB;;;;;;ECYhC,OAAA,EAAS,OAAA;EDiBF;AAAA;AAGT;ECfE,MAAA,EAAQ,MAAA;;;;EAKR,OAAA,EAAS,OAAA;ED6BgB;;;ECxBzB,UAAA,EAAY,kBAAA;AAAA;AAAA,UAGG,gBAAA,0DAKP,cAAA,EAAgB,SAAA,CAAU,KAAA,EAAO,QAAA;EDWnC;;;ECPN,OAAA,EAAS,QAAA;EDYgB;;;EAAA,ICPrB,IAAA,IAAQ,KAAA;EAjDG;;;EAAA,IAsDX,MAAA,IAAU,QAAA,CAAS,KAAA,EAAO,QAAA;EArCrB;;;EAAA,IA0CL,KAAA,IAAS,KAAA,CAAM,KAAA,EAAO,QAAA;EA3BI;;;EAAA,IAgC1B,MAAA,IAAU,MAAA,CAAO,KAAA,EAAO,QAAA,EAAU,QAAA;EAvD5B;;;EAAA,IA4DN,SAAA,IAAa,MAAA,SAAe,iBAAA,CAAkB,KAAA,EAAO,QAAA;EA/CjD;;;;;;EAuDR,WAAA,GACE,cAAA,WAAyB,iBAAA,CAAkB,KAAA,EAAO,QAAA,GAClD,QAAA,GAAW,IAAA,CAAK,iBAAA,CAAkB,KAAA,EAAO,QAAA;AAAA"}
@@ -0,0 +1,129 @@
1
+ import { A as ExtractedExecution, E as ExecutionDocument, K as SchemaOf, P as Input, T as Execution, c as Settings, s as Logger, u as Output } from "./config-B6Gr29ZK.mjs";
2
+ import { Storage } from "unstorage";
3
+
4
+ //#region src/types/session.d.ts
5
+ interface SessionUserInfo {
6
+ /**
7
+ * The user name for the active session.
8
+ */
9
+ name: string;
10
+ /**
11
+ * The display name for the active user.
12
+ */
13
+ displayName: string;
14
+ /**
15
+ * The user's language preferences.
16
+ */
17
+ languagePreferences: string[];
18
+ }
19
+ interface SessionDeviceInfo {
20
+ /**
21
+ * The device name for the active session.
22
+ */
23
+ name: string;
24
+ /**
25
+ * The display name for the active device.
26
+ */
27
+ displayName: string;
28
+ /**
29
+ * The platform identifier for the active device.
30
+ */
31
+ platform: string;
32
+ /**
33
+ * The OS distribution for the active device.
34
+ */
35
+ distro: string;
36
+ /**
37
+ * The desktop environment for the active device.
38
+ */
39
+ desktopEnv: string;
40
+ /**
41
+ * The CPU architecture for the active device.
42
+ */
43
+ cpuArch: string;
44
+ }
45
+ interface Session {
46
+ /**
47
+ * A unique identifier for the session.
48
+ */
49
+ sessionId: string;
50
+ /**
51
+ * The timestamp indicating when the session started.
52
+ */
53
+ startedAt: Date;
54
+ /**
55
+ * Information about the current user.
56
+ */
57
+ user: SessionUserInfo;
58
+ /**
59
+ * Information about the current device.
60
+ */
61
+ device: SessionDeviceInfo;
62
+ }
63
+ //#endregion
64
+ //#region src/types/context.d.ts
65
+ interface SessionContext {
66
+ /**
67
+ * The current working directory.
68
+ */
69
+ cwd: string;
70
+ /**
71
+ * The settings for the context.
72
+ */
73
+ settings: Settings;
74
+ /**
75
+ * The Unstorage storage for the context.
76
+ *
77
+ * @remarks
78
+ * This storage can be used to store the input and output of the execution.
79
+ */
80
+ storage: Storage;
81
+ /**
82
+ * The logger for the context.
83
+ */
84
+ logger: Logger;
85
+ /**
86
+ * The session for the context.
87
+ */
88
+ session: Session;
89
+ /**
90
+ * The executions that have been performed in the context.
91
+ */
92
+ executions: ExtractedExecution<any, any>[];
93
+ }
94
+ interface ExecutionContext<TSpec, TOptions extends object, TReturns = void> extends SessionContext, Execution<TSpec, TOptions> {
95
+ /**
96
+ * The options for the execution.
97
+ */
98
+ options: TOptions;
99
+ /**
100
+ * The specification for the execution.
101
+ */
102
+ get spec(): TSpec;
103
+ /**
104
+ * The schema for the execution.
105
+ */
106
+ get schema(): SchemaOf<TSpec, TOptions>;
107
+ /**
108
+ * The input for the execution.
109
+ */
110
+ get input(): Input<TSpec, TOptions>;
111
+ /**
112
+ * The output for the execution.
113
+ */
114
+ get output(): Output<TSpec, TOptions, TReturns>;
115
+ /**
116
+ * The documents that are currently being processed, indexed by the document path.
117
+ */
118
+ get documents(): Record<string, ExecutionDocument<TSpec, TOptions>>;
119
+ /**
120
+ * Adds a document to the currently processing documents.
121
+ *
122
+ * @param pathOrDocument - A string representing the path of the document to add, or the document to add.
123
+ * @param document - The document to add (without the path), if {@link pathOrDocument} is a string representing the document path.
124
+ */
125
+ addDocument: (pathOrDocument: string | ExecutionDocument<TSpec, TOptions>, document?: Omit<ExecutionDocument<TSpec, TOptions>, "path">) => void;
126
+ }
127
+ //#endregion
128
+ export { SessionUserInfo as a, SessionDeviceInfo as i, SessionContext as n, Session as r, ExecutionContext as t };
129
+ //# sourceMappingURL=context-neyaFruu.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-neyaFruu.d.mts","names":[],"sources":["../src/types/session.ts","../src/types/context.ts"],"mappings":""}
@@ -0,0 +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;
@@ -0,0 +1,91 @@
1
+ import { n as SessionContext, t as ExecutionContext } from "./context-QCvV8cA9.cjs";
2
+ import { AsyncLocalStorage } from "node:async_hooks";
3
+
4
+ //#region src/context.d.ts
5
+ /**
6
+ * The context store for a specific context.
7
+ */
8
+ interface ContextStore<TContext extends SessionContext> {
9
+ asyncLocalStorage: AsyncLocalStorage<TContext>;
10
+ use: () => TContext;
11
+ tryUse: () => TContext | undefined;
12
+ call: <R>(instance: TContext, callback: () => R) => R;
13
+ callAsync: <R>(instance: TContext, callback: () => R | Promise<R>) => Promise<R>;
14
+ }
15
+ /**
16
+ * The context store for the session context.
17
+ */
18
+ declare const sessionContext: ContextStore<SessionContext>;
19
+ /**
20
+ * The async local storage for the session context.
21
+ */
22
+ declare const sessionAsyncLocalStorage: AsyncLocalStorage<SessionContext>;
23
+ /**
24
+ * The function to use the session context.
25
+ *
26
+ * @returns The session context.
27
+ * @throws An error if the session context is not available.
28
+ */
29
+ declare const useSessionContext: () => SessionContext;
30
+ /**
31
+ * The function to try to use the session context.
32
+ *
33
+ * @returns The session context or undefined if the session context is not available.
34
+ */
35
+ declare const tryUseSessionContext: () => SessionContext | undefined;
36
+ /**
37
+ * The function to call the session context.
38
+ *
39
+ * @param instance - The instance of the session context.
40
+ * @param callback - The callback to call.
41
+ * @returns The result of the callback.
42
+ */
43
+ declare const callSessionContext: <R>(instance: SessionContext, callback: () => R) => R;
44
+ /**
45
+ * The function to call the session context asynchronously.
46
+ *
47
+ * @param instance - The instance of the session context.
48
+ * @param callback - The callback to call.
49
+ * @returns The result of the callback.
50
+ */
51
+ declare const callAsyncSessionContext: <R>(instance: SessionContext, callback: () => R | Promise<R>) => Promise<R>;
52
+ /**
53
+ * The context store for the execution context. This is used to store the execution context for a specific execution.
54
+ */
55
+ declare const executionContext: ContextStore<ExecutionContext<any, any, any>>;
56
+ /**
57
+ * The async local storage for the execution context. This is used to store the execution context for a specific execution.
58
+ */
59
+ declare const executionAsyncLocalStorage: AsyncLocalStorage<ExecutionContext<any, any, any>>;
60
+ /**
61
+ * The function to use the execution context.
62
+ *
63
+ * @returns The execution context.
64
+ * @throws An error if the execution context is not available.
65
+ */
66
+ declare const useExecutionContext: () => ExecutionContext<any, any, any>;
67
+ /**
68
+ * The function to try to use the execution context.
69
+ *
70
+ * @returns The execution context or undefined if the execution context is not available.
71
+ */
72
+ declare const tryUseExecutionContext: () => ExecutionContext<any, any, any> | undefined;
73
+ /**
74
+ * The function to call the execution context.
75
+ *
76
+ * @param instance - The instance of the execution context.
77
+ * @param callback - The callback to call.
78
+ * @returns The result of the callback.
79
+ */
80
+ declare const callExecutionContext: <R>(instance: ExecutionContext<any, any, any>, callback: () => R) => R;
81
+ /**
82
+ * The function to call the execution context asynchronously.
83
+ *
84
+ * @param instance - The instance of the execution context.
85
+ * @param callback - The callback to call.
86
+ * @returns The result of the callback.
87
+ */
88
+ declare const callAsyncExecutionContext: <R>(instance: ExecutionContext<any, any, any>, callback: () => R | Promise<R>) => Promise<R>;
89
+ //#endregion
90
+ export { ContextStore, callAsyncExecutionContext, callAsyncSessionContext, callExecutionContext, callSessionContext, executionAsyncLocalStorage, executionContext, sessionAsyncLocalStorage, sessionContext, tryUseExecutionContext, tryUseSessionContext, useExecutionContext, useSessionContext };
91
+ //# sourceMappingURL=context.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.cts","names":[],"sources":["../src/context.ts"],"mappings":";;;;;;AA0BA;UAAiB,YAAA,kBAA8B,cAAA;EAC7C,iBAAA,EAAmB,iBAAA,CAAkB,QAAA;EACrC,GAAA,QAAW,QAAA;EACX,MAAA,QAAc,QAAA;EACd,IAAA,MAAU,QAAA,EAAU,QAAA,EAAU,QAAA,QAAgB,CAAA,KAAM,CAAA;EACpD,SAAA,MACE,QAAA,EAAU,QAAA,EACV,QAAA,QAAgB,CAAA,GAAI,OAAA,CAAQ,CAAA,MACzB,OAAA,CAAQ,CAAA;AAAA;;;;cAyDF,cAAA,EAAc,YAAA,CAAA,cAAA;;;;cAKd,wBAAA,EAAwB,iBAAA,CAAA,cAAA;;;;;;;cAQxB,iBAAA,QAAiB,cAAqB;;;;;;cAOtC,oBAAA,QAAoB,cAAA;;;;;;;;cASpB,kBAAA,MA1FH,QAAA,EAAA,cAAA,EAAA,QAAA,QAAA,CAAA,KAAA,CAAA;;;;;;;;cAmGG,uBAAA,MAlGE,QAAA,EAAA,cAAA,EAAA,QAAA,QAAA,CAAA,GAAA,OAAA,CAAA,CAAA,MAAA,OAAA,CAAA,CAAA;;AAGC;AAyDhB;cA2Ca,gBAAA,EAAgB,YAAA,CAAA,gBAAA;;;AA3CF;cAiDd,0BAAA,EAA0B,iBAAA,CAAA,gBAAA;;;;AA5CF;AAQrC;;cA4Ca,mBAAA,QAAmB,gBAAA;;AA5CmB;AAOnD;;;cA4Ca,sBAAA,QAAsB,gBAAA;AA5CF;AASjC;;;;;;AATiC,cAqDpB,oBAAA,MAtIH,QAAA,EAAA,gBAAA,iBAAA,QAAA,QAAA,CAAA,KAAA,CAAA;;;;;;;;cA+IG,yBAAA,MA9IE,QAAA,EAAA,gBAAA,iBAAA,QAAA,QAAA,CAAA,GAAA,OAAA,CAAA,CAAA,MAAA,OAAA,CAAA,CAAA"}
@@ -0,0 +1,91 @@
1
+ import { n as SessionContext, t as ExecutionContext } from "./context-neyaFruu.mjs";
2
+ import { AsyncLocalStorage } from "node:async_hooks";
3
+
4
+ //#region src/context.d.ts
5
+ /**
6
+ * The context store for a specific context.
7
+ */
8
+ interface ContextStore<TContext extends SessionContext> {
9
+ asyncLocalStorage: AsyncLocalStorage<TContext>;
10
+ use: () => TContext;
11
+ tryUse: () => TContext | undefined;
12
+ call: <R>(instance: TContext, callback: () => R) => R;
13
+ callAsync: <R>(instance: TContext, callback: () => R | Promise<R>) => Promise<R>;
14
+ }
15
+ /**
16
+ * The context store for the session context.
17
+ */
18
+ declare const sessionContext: ContextStore<SessionContext>;
19
+ /**
20
+ * The async local storage for the session context.
21
+ */
22
+ declare const sessionAsyncLocalStorage: AsyncLocalStorage<SessionContext>;
23
+ /**
24
+ * The function to use the session context.
25
+ *
26
+ * @returns The session context.
27
+ * @throws An error if the session context is not available.
28
+ */
29
+ declare const useSessionContext: () => SessionContext;
30
+ /**
31
+ * The function to try to use the session context.
32
+ *
33
+ * @returns The session context or undefined if the session context is not available.
34
+ */
35
+ declare const tryUseSessionContext: () => SessionContext | undefined;
36
+ /**
37
+ * The function to call the session context.
38
+ *
39
+ * @param instance - The instance of the session context.
40
+ * @param callback - The callback to call.
41
+ * @returns The result of the callback.
42
+ */
43
+ declare const callSessionContext: <R>(instance: SessionContext, callback: () => R) => R;
44
+ /**
45
+ * The function to call the session context asynchronously.
46
+ *
47
+ * @param instance - The instance of the session context.
48
+ * @param callback - The callback to call.
49
+ * @returns The result of the callback.
50
+ */
51
+ declare const callAsyncSessionContext: <R>(instance: SessionContext, callback: () => R | Promise<R>) => Promise<R>;
52
+ /**
53
+ * The context store for the execution context. This is used to store the execution context for a specific execution.
54
+ */
55
+ declare const executionContext: ContextStore<ExecutionContext<any, any, any>>;
56
+ /**
57
+ * The async local storage for the execution context. This is used to store the execution context for a specific execution.
58
+ */
59
+ declare const executionAsyncLocalStorage: AsyncLocalStorage<ExecutionContext<any, any, any>>;
60
+ /**
61
+ * The function to use the execution context.
62
+ *
63
+ * @returns The execution context.
64
+ * @throws An error if the execution context is not available.
65
+ */
66
+ declare const useExecutionContext: () => ExecutionContext<any, any, any>;
67
+ /**
68
+ * The function to try to use the execution context.
69
+ *
70
+ * @returns The execution context or undefined if the execution context is not available.
71
+ */
72
+ declare const tryUseExecutionContext: () => ExecutionContext<any, any, any> | undefined;
73
+ /**
74
+ * The function to call the execution context.
75
+ *
76
+ * @param instance - The instance of the execution context.
77
+ * @param callback - The callback to call.
78
+ * @returns The result of the callback.
79
+ */
80
+ declare const callExecutionContext: <R>(instance: ExecutionContext<any, any, any>, callback: () => R) => R;
81
+ /**
82
+ * The function to call the execution context asynchronously.
83
+ *
84
+ * @param instance - The instance of the execution context.
85
+ * @param callback - The callback to call.
86
+ * @returns The result of the callback.
87
+ */
88
+ declare const callAsyncExecutionContext: <R>(instance: ExecutionContext<any, any, any>, callback: () => R | Promise<R>) => Promise<R>;
89
+ //#endregion
90
+ export { ContextStore, callAsyncExecutionContext, callAsyncSessionContext, callExecutionContext, callSessionContext, executionAsyncLocalStorage, executionContext, sessionAsyncLocalStorage, sessionContext, tryUseExecutionContext, tryUseSessionContext, useExecutionContext, useSessionContext };
91
+ //# sourceMappingURL=context.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.mts","names":[],"sources":["../src/context.ts"],"mappings":""}
@@ -0,0 +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};
2
+ //# sourceMappingURL=context.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.mjs","names":[],"sources":[],"mappings":""}
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./type-checks.cjs");function t(t){return e.isInputConfigObject(t)?t:{input:t}}function n(t){return e.isOutputConfigObject(t)?t:{output:t}}function r(t){return e.isSchemaConfigObject(t)?t:{schema:t}}function i(t){if(!e.isGeneratorConfigObject(t))throw TypeError(`An invalid generator configuration was provided - at minimum, a generator function is required.`);return t}exports.defineGenerator=i,exports.defineInput=t,exports.defineOutput=n,exports.defineSchema=r;
@@ -0,0 +1,82 @@
1
+ import { F as InputConfig, H as SchemaConfigObject, I as InputConfigObject, d as OutputConfig, f as OutputConfigObject, y as GeneratorConfigObject } from "./config-B6Gr29ZK.cjs";
2
+ import { SchemaEnvelopeOf, SchemaSourceConfig } from "@power-plant/schema";
3
+
4
+ //#region src/define.d.ts
5
+ /**
6
+ * Defines a input configuration object. If the provided input is already a input configuration object, it will be returned as-is. Otherwise, it will be wrapped in an object with a `input` property.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { defineInput } from "@power-plant/core";
11
+ *
12
+ * // Define a input from a input function
13
+ * export default defineInput((options) => {
14
+ * // Your input logic here
15
+ * });
16
+ *
17
+ * // Define a input from an existing input input object
18
+ * export default defineInput({
19
+ * meta: {
20
+ * name: "My Input",
21
+ * version: "1.0.0",
22
+ * description: "A input that does something.",
23
+ * },
24
+ * schema: z.object({
25
+ * // Your schema definition here
26
+ * }),
27
+ * input: (options) => {
28
+ * // Your input logic here
29
+ * },
30
+ * });
31
+ * ```
32
+ *
33
+ * @param input - The input input to define. This can be either a input input object or a input function.
34
+ * @returns A input input object that contains the provided input. If the input was already a input input object, it will be returned unchanged.
35
+ */
36
+ declare function defineInput<TSpec, TOptions extends object>(input: InputConfig<TSpec, TOptions>): InputConfigObject<TSpec, TOptions>;
37
+ /**
38
+ * Defines a output configuration object. If the provided output is already a output configuration object, it will be returned as-is. Otherwise, it will be wrapped in an object with a `output` property.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * import { defineOutput } from "@power-plant/core";
43
+ *
44
+ * // Define a output from a output function
45
+ * export default defineOutput((result, spec, options) => {
46
+ * // Your output logic here
47
+ * });
48
+ *
49
+ * // Define a output from an existing output configuration object
50
+ * export default defineOutput({
51
+ * meta: {
52
+ * name: "My Output",
53
+ * version: "1.0.0",
54
+ * description: "A output that does something.",
55
+ * },
56
+ * output: (result, spec, options) => {
57
+ * // Your output logic here
58
+ * },
59
+ * });
60
+ * ```
61
+ *
62
+ * @param output - The output configuration to define. This can be either a output configuration object or a output function.
63
+ * @returns A output configuration object that contains the provided output. If the input was already a output configuration object, it will be returned unchanged.
64
+ */
65
+ declare function defineOutput<TSpec, TOptions extends object, TReturns = void>(output: OutputConfig<TSpec, TOptions, TReturns>): OutputConfigObject<TSpec, TOptions, TReturns>;
66
+ /**
67
+ * 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.
68
+ *
69
+ * @param schema - The schema configuration to define. This can be either a schema source configuration, a schema envelope, or a schema configuration object.
70
+ * @returns A schema configuration object that contains the provided schema. If the input was already a schema configuration object, it will be returned unchanged.
71
+ */
72
+ declare function defineSchema<TSpec, TOptions extends object>(schema: SchemaSourceConfig<TSpec> | SchemaEnvelopeOf<TSpec> | SchemaConfigObject<TSpec, TOptions>): SchemaConfigObject<TSpec, TOptions>;
73
+ /**
74
+ * 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.
75
+ *
76
+ * @param generator - The schema configuration to define. This can be either a schema source configuration, a schema envelope, or a schema configuration object.
77
+ * @returns A schema configuration object that contains the provided schema. If the input was already a schema configuration object, it will be returned unchanged.
78
+ */
79
+ declare function defineGenerator<TSpec, TOptions extends object, TReturns = void>(generator: GeneratorConfigObject<TSpec, TOptions, TReturns>): GeneratorConfigObject<TSpec, TOptions, TReturns>;
80
+ //#endregion
81
+ export { defineGenerator, defineInput, defineOutput, defineSchema };
82
+ //# sourceMappingURL=define.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.d.cts","names":[],"sources":["../src/define.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA+DoC;AAoCpC;;;;;;;;;;iBAtCgB,WAAA,iCACd,KAAA,EAAO,WAAA,CAAY,KAAA,EAAO,QAAA,IACzB,iBAAA,CAAkB,KAAA,EAAO,QAAA;;;;;;;;;;;;;;;;AAsCmB;AAc/C;;;;;;;;;;;;iBAhBgB,YAAA,kDACd,MAAA,EAAQ,YAAA,CAAa,KAAA,EAAO,QAAA,EAAU,QAAA,IACrC,kBAAA,CAAmB,KAAA,EAAO,QAAA,EAAU,QAAA;;;;;;;iBAcvB,YAAA,iCACd,MAAA,EACI,kBAAA,CAAmB,KAAA,IACnB,gBAAA,CAAiB,KAAA,IACjB,kBAAA,CAAmB,KAAA,EAAO,QAAA,IAC7B,kBAAA,CAAmB,KAAA,EAAO,QAAA;;;;;;;iBAcb,eAAA,kDAKd,SAAA,EAAW,qBAAA,CAAsB,KAAA,EAAO,QAAA,EAAU,QAAA,IACjD,qBAAA,CAAsB,KAAA,EAAO,QAAA,EAAU,QAAA"}
@@ -0,0 +1,82 @@
1
+ import { F as InputConfig, H as SchemaConfigObject, I as InputConfigObject, d as OutputConfig, f as OutputConfigObject, y as GeneratorConfigObject } from "./config-B6Gr29ZK.mjs";
2
+ import { SchemaEnvelopeOf, SchemaSourceConfig } from "@power-plant/schema";
3
+
4
+ //#region src/define.d.ts
5
+ /**
6
+ * Defines a input configuration object. If the provided input is already a input configuration object, it will be returned as-is. Otherwise, it will be wrapped in an object with a `input` property.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { defineInput } from "@power-plant/core";
11
+ *
12
+ * // Define a input from a input function
13
+ * export default defineInput((options) => {
14
+ * // Your input logic here
15
+ * });
16
+ *
17
+ * // Define a input from an existing input input object
18
+ * export default defineInput({
19
+ * meta: {
20
+ * name: "My Input",
21
+ * version: "1.0.0",
22
+ * description: "A input that does something.",
23
+ * },
24
+ * schema: z.object({
25
+ * // Your schema definition here
26
+ * }),
27
+ * input: (options) => {
28
+ * // Your input logic here
29
+ * },
30
+ * });
31
+ * ```
32
+ *
33
+ * @param input - The input input to define. This can be either a input input object or a input function.
34
+ * @returns A input input object that contains the provided input. If the input was already a input input object, it will be returned unchanged.
35
+ */
36
+ declare function defineInput<TSpec, TOptions extends object>(input: InputConfig<TSpec, TOptions>): InputConfigObject<TSpec, TOptions>;
37
+ /**
38
+ * Defines a output configuration object. If the provided output is already a output configuration object, it will be returned as-is. Otherwise, it will be wrapped in an object with a `output` property.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * import { defineOutput } from "@power-plant/core";
43
+ *
44
+ * // Define a output from a output function
45
+ * export default defineOutput((result, spec, options) => {
46
+ * // Your output logic here
47
+ * });
48
+ *
49
+ * // Define a output from an existing output configuration object
50
+ * export default defineOutput({
51
+ * meta: {
52
+ * name: "My Output",
53
+ * version: "1.0.0",
54
+ * description: "A output that does something.",
55
+ * },
56
+ * output: (result, spec, options) => {
57
+ * // Your output logic here
58
+ * },
59
+ * });
60
+ * ```
61
+ *
62
+ * @param output - The output configuration to define. This can be either a output configuration object or a output function.
63
+ * @returns A output configuration object that contains the provided output. If the input was already a output configuration object, it will be returned unchanged.
64
+ */
65
+ declare function defineOutput<TSpec, TOptions extends object, TReturns = void>(output: OutputConfig<TSpec, TOptions, TReturns>): OutputConfigObject<TSpec, TOptions, TReturns>;
66
+ /**
67
+ * 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.
68
+ *
69
+ * @param schema - The schema configuration to define. This can be either a schema source configuration, a schema envelope, or a schema configuration object.
70
+ * @returns A schema configuration object that contains the provided schema. If the input was already a schema configuration object, it will be returned unchanged.
71
+ */
72
+ declare function defineSchema<TSpec, TOptions extends object>(schema: SchemaSourceConfig<TSpec> | SchemaEnvelopeOf<TSpec> | SchemaConfigObject<TSpec, TOptions>): SchemaConfigObject<TSpec, TOptions>;
73
+ /**
74
+ * 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.
75
+ *
76
+ * @param generator - The schema configuration to define. This can be either a schema source configuration, a schema envelope, or a schema configuration object.
77
+ * @returns A schema configuration object that contains the provided schema. If the input was already a schema configuration object, it will be returned unchanged.
78
+ */
79
+ declare function defineGenerator<TSpec, TOptions extends object, TReturns = void>(generator: GeneratorConfigObject<TSpec, TOptions, TReturns>): GeneratorConfigObject<TSpec, TOptions, TReturns>;
80
+ //#endregion
81
+ export { defineGenerator, defineInput, defineOutput, defineSchema };
82
+ //# sourceMappingURL=define.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.d.mts","names":[],"sources":["../src/define.ts"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{isGeneratorConfigObject as e,isInputConfigObject as t,isOutputConfigObject as n,isSchemaConfigObject as r}from"./type-checks.mjs";function i(e){return t(e)?e:{input:e}}function a(e){return n(e)?e:{output:e}}function o(e){return r(e)?e:{schema:e}}function s(t){if(!e(t))throw TypeError(`An invalid generator configuration was provided - at minimum, a generator function is required.`);return t}export{s as defineGenerator,i as defineInput,a as defineOutput,o as defineSchema};
2
+ //# sourceMappingURL=define.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.mjs","names":[],"sources":[],"mappings":""}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./context-Bcrz4kGb.cjs"),t=require("./helpers-Botqc1jf.cjs"),n=require("./define-DVggP_03.cjs"),r=require("./define-C_GLY1-q.cjs"),i=require("./define-B__DotaM.cjs");exports.asyncLocalStorage=e.t,exports.callAsyncContext=e.n,exports.callContext=e.r,exports.context=e.i,exports.createContext=e.a,exports.defineGenerator=e.c,exports.defineInput=n.t,exports.defineOutput=r.t,exports.defineSchema=i.t,exports.extractMeta=t.n,exports.formatMetaVersion=t.r,exports.resolveMetaDescription=t.i,exports.resolveMetaExample=t.a,exports.resolveMetaId=t.o,exports.resolveMetaLinks=t.s,exports.resolveMetaName=t.c,exports.resolveMetaTitle=t.l,exports.resolveMetaVersion=t.u,exports.tryUseContext=e.o,exports.useContext=e.s;
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;