swarpc 0.7.0 → 0.8.0

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 (46) hide show
  1. package/dist/client.d.ts +39 -0
  2. package/dist/client.d.ts.map +1 -0
  3. package/dist/{src/client.js → client.js} +11 -3
  4. package/dist/{src/index.d.ts → index.d.ts} +4 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/{src/index.js → index.js} +4 -0
  7. package/dist/log.d.ts +28 -0
  8. package/dist/log.d.ts.map +1 -0
  9. package/dist/log.js +55 -0
  10. package/dist/server.d.ts +32 -0
  11. package/dist/server.d.ts.map +1 -0
  12. package/dist/{src/server.js → server.js} +18 -10
  13. package/dist/{src/types.d.ts → types.d.ts} +44 -23
  14. package/dist/types.d.ts.map +1 -0
  15. package/dist/{src/types.js → types.js} +17 -0
  16. package/dist/utils.d.ts.map +1 -0
  17. package/package.json +18 -5
  18. package/src/client.ts +22 -4
  19. package/src/index.ts +5 -0
  20. package/src/log.ts +68 -12
  21. package/src/server.ts +37 -16
  22. package/src/types.ts +43 -31
  23. package/dist/src/client.d.ts +0 -22
  24. package/dist/src/client.d.ts.map +0 -1
  25. package/dist/src/index.d.ts.map +0 -1
  26. package/dist/src/log.d.ts +0 -20
  27. package/dist/src/log.d.ts.map +0 -1
  28. package/dist/src/log.js +0 -45
  29. package/dist/src/server.d.ts +0 -15
  30. package/dist/src/server.d.ts.map +0 -1
  31. package/dist/src/types.d.ts.map +0 -1
  32. package/dist/src/utils.d.ts.map +0 -1
  33. package/dist/tests/core.procedures.d.ts +0 -45
  34. package/dist/tests/core.procedures.d.ts.map +0 -1
  35. package/dist/tests/core.procedures.js +0 -49
  36. package/dist/tests/core.test.d.ts +0 -2
  37. package/dist/tests/core.test.d.ts.map +0 -1
  38. package/dist/tests/core.test.js +0 -100
  39. package/dist/tests/core.worker.d.ts +0 -2
  40. package/dist/tests/core.worker.d.ts.map +0 -1
  41. package/dist/tests/core.worker.js +0 -30
  42. package/dist/vite.config.d.ts +0 -3
  43. package/dist/vite.config.d.ts.map +0 -1
  44. package/dist/vite.config.js +0 -7
  45. /package/dist/{src/utils.d.ts → utils.d.ts} +0 -0
  46. /package/dist/{src/utils.js → utils.js} +0 -0
package/src/log.ts CHANGED
@@ -1,30 +1,86 @@
1
+ /**
2
+ * @module
3
+ * @mergeModuleWith <project>
4
+ */
5
+
6
+ /**
7
+ * @ignore
8
+ */
9
+ export function createLogger(side: "server" | "client", level: LogLevel): Logger
1
10
  export function createLogger(
2
11
  side: "server" | "client",
3
- level: LogLevel = "debug"
12
+ level: LogLevel,
13
+ rqid: string
14
+ ): RequestBoundLogger
15
+ export function createLogger(
16
+ side: "server" | "client",
17
+ level: LogLevel = "debug",
18
+ rqid?: string
4
19
  ) {
5
- const enabledLevels = LOG_LEVELS.slice(LOG_LEVELS.indexOf(level))
20
+ const lvls = LOG_LEVELS.slice(LOG_LEVELS.indexOf(level))
21
+
22
+ if (rqid) {
23
+ return {
24
+ debug: lvls.includes("debug") ? logger("debug", side, rqid) : () => {},
25
+ info: lvls.includes("info") ? logger("info", side, rqid) : () => {},
26
+ warn: lvls.includes("warn") ? logger("warn", side, rqid) : () => {},
27
+ error: lvls.includes("error") ? logger("error", side, rqid) : () => {},
28
+ } as RequestBoundLogger
29
+ }
6
30
 
7
31
  return {
8
- debug: enabledLevels.includes("debug") ? logger("debug", side) : () => {},
9
- info: enabledLevels.includes("info") ? logger("info", side) : () => {},
10
- warn: enabledLevels.includes("warn") ? logger("warn", side) : () => {},
11
- error: enabledLevels.includes("error") ? logger("error", side) : () => {},
32
+ debug: lvls.includes("debug") ? logger("debug", side) : () => {},
33
+ info: lvls.includes("info") ? logger("info", side) : () => {},
34
+ warn: lvls.includes("warn") ? logger("warn", side) : () => {},
35
+ error: lvls.includes("error") ? logger("error", side) : () => {},
12
36
  }
13
37
  }
14
38
 
15
- export type Logger = ReturnType<typeof createLogger>
39
+ /**
40
+ * @ignore
41
+ */
42
+ export type Logger = {
43
+ debug: (rqid: string | null, message: string, ...args: any[]) => void
44
+ info: (rqid: string | null, message: string, ...args: any[]) => void
45
+ warn: (rqid: string | null, message: string, ...args: any[]) => void
46
+ error: (rqid: string | null, message: string, ...args: any[]) => void
47
+ }
48
+
49
+ export type RequestBoundLogger = {
50
+ debug: (message: string, ...args: any[]) => void
51
+ info: (message: string, ...args: any[]) => void
52
+ warn: (message: string, ...args: any[]) => void
53
+ error: (message: string, ...args: any[]) => void
54
+ }
55
+
56
+ /** @source */
57
+ export const LOG_LEVELS = ["debug", "info", "warn", "error"] as const
16
58
 
17
- const LOG_LEVELS = ["debug", "info", "warn", "error"] as const
18
59
  export type LogLevel = (typeof LOG_LEVELS)[number]
19
60
 
20
61
  /**
21
- * Creates partially-applied logging functions given the first 2 args
62
+ * Creates partially-applied logging functions given the first 2 or 3 args
22
63
  * @param severity
23
64
  * @param side
65
+ * @param rqid request ID, or null to not bind it
24
66
  * @returns
25
67
  */
26
- function logger(severity: LogLevel, side: "server" | "client") {
27
- return (rqid: string | null, message: string, ...args: any[]) =>
68
+ function logger(
69
+ severity: LogLevel,
70
+ side: "server" | "client",
71
+ rqid: string
72
+ ): (message: string, ...args: any[]) => void
73
+ function logger(
74
+ severity: LogLevel,
75
+ side: "server" | "client"
76
+ ): (rqid: string | null, message: string, ...args: any[]) => void
77
+ function logger(severity: LogLevel, side: "server" | "client", rqid?: string) {
78
+ if (rqid === undefined) {
79
+ return (rqid: string | null, message: string, ...args: any[]) =>
80
+ log(severity, side, rqid, message, ...args)
81
+ }
82
+
83
+ return (message: string, ...args: any[]) =>
28
84
  log(severity, side, rqid, message, ...args)
29
85
  }
30
86
 
@@ -36,7 +92,7 @@ function logger(severity: LogLevel, side: "server" | "client") {
36
92
  * @param message
37
93
  * @param args passed to console methods directly
38
94
  */
39
- export function log(
95
+ function log(
40
96
  severity: "debug" | "info" | "warn" | "error",
41
97
  side: "server" | "client",
42
98
  rqid: string | null,
package/src/server.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @module
3
+ * @mergeModuleWith <project>
4
+ */
5
+
1
6
  import { type } from "arktype"
2
7
  import { createLogger, type LogLevel } from "./log.js"
3
8
  import {
@@ -6,24 +11,43 @@ import {
6
11
  PayloadCore,
7
12
  PayloadHeaderSchema,
8
13
  PayloadSchema,
14
+ ProcedureImplementation,
9
15
  zImplementations,
10
16
  zProcedures,
11
17
  type ProceduresMap,
12
- type SwarpcServer,
13
18
  } from "./types.js"
14
19
  import { findTransferables } from "./utils.js"
15
20
 
16
- export type { SwarpcServer } from "./types.js"
21
+ /**
22
+ * The sw&rpc server instance, which provides methods to register {@link ProcedureImplementation | procedure implementations},
23
+ * and listens for incoming messages that call those procedures
24
+ */
25
+ export type SwarpcServer<Procedures extends ProceduresMap> = {
26
+ [zProcedures]: Procedures
27
+ [zImplementations]: ImplementationsMap<Procedures>
28
+ start(self: Window | Worker): void
29
+ } & {
30
+ [F in keyof Procedures]: (
31
+ impl: ProcedureImplementation<
32
+ Procedures[F]["input"],
33
+ Procedures[F]["progress"],
34
+ Procedures[F]["success"]
35
+ >
36
+ ) => void
37
+ }
17
38
 
18
39
  const abortControllers = new Map<string, AbortController>()
19
40
  const abortedRequests = new Set<string>()
20
41
 
21
42
  /**
22
43
  * Creates a sw&rpc server instance.
23
- * @param procedures procedures the server will implement
44
+ * @param procedures procedures the server will implement, see {@link ProceduresMap}
24
45
  * @param options various options
25
46
  * @param options.worker if provided, the server will use this worker to post messages, instead of sending it to all clients
26
- * @returns a SwarpcServer instance. Each property of the procedures map will be a method, that accepts a function implementing the procedure. There is also .start(), to be called after implementing all procedures.
47
+ * @returns a SwarpcServer instance. Each property of the procedures map will be a method, that accepts a function implementing the procedure (see {@link ProcedureImplementation}). There is also .start(), to be called after implementing all procedures.
48
+ *
49
+ * An example of defining a server:
50
+ * {@includeCode ../example/src/service-worker.ts}
27
51
  */
28
52
  export function Server<Procedures extends ProceduresMap>(
29
53
  procedures: Procedures,
@@ -46,22 +70,16 @@ export function Server<Procedures extends ProceduresMap>(
46
70
  if (!instance[zProcedures][functionName]) {
47
71
  throw new Error(`No procedure found for function name: ${functionName}`)
48
72
  }
49
- instance[zImplementations][functionName] = (
50
- input,
51
- onProgress,
52
- abortSignal
53
- ) => {
54
- abortSignal?.throwIfAborted()
73
+ instance[zImplementations][functionName] = (input, onProgress, tools) => {
74
+ tools.abortSignal?.throwIfAborted()
55
75
  return new Promise((resolve, reject) => {
56
- abortSignal?.addEventListener("abort", () => {
57
- let { requestId, reason } = abortSignal?.reason
76
+ tools.abortSignal?.addEventListener("abort", () => {
77
+ let { requestId, reason } = tools.abortSignal?.reason
58
78
  l.debug(requestId, `Aborted ${functionName} request: ${reason}`)
59
79
  reject({ aborted: reason })
60
80
  })
61
81
 
62
- implementation(input, onProgress, abortSignal)
63
- .then(resolve)
64
- .catch(reject)
82
+ implementation(input, onProgress, tools).then(resolve).catch(reject)
65
83
  })
66
84
  }
67
85
  }) as SwarpcServer<Procedures>[typeof functionName]
@@ -159,7 +177,10 @@ export function Server<Procedures extends ProceduresMap>(
159
177
  l.debug(requestId, `Progress for ${functionName}`, progress)
160
178
  await postMsg({ progress })
161
179
  },
162
- abortControllers.get(requestId)?.signal
180
+ {
181
+ abortSignal: abortControllers.get(requestId)?.signal,
182
+ logger: createLogger("server", loglevel, requestId),
183
+ }
163
184
  )
164
185
  // Send errors
165
186
  .catch(async (error: any) => {
package/src/types.ts CHANGED
@@ -1,4 +1,10 @@
1
+ /**
2
+ * @module
3
+ * @mergeModuleWith <project>
4
+ */
5
+
1
6
  import { type, type Type } from "arktype"
7
+ import { Logger, RequestBoundLogger } from "./log.js"
2
8
 
3
9
  /**
4
10
  * A procedure declaration
@@ -39,7 +45,7 @@ export type Procedure<I extends Type, P extends Type, S extends Type> = {
39
45
  * const result = await request
40
46
  * ```
41
47
  */
42
- export type CancelablePromise<T> = {
48
+ export type CancelablePromise<T = unknown> = {
43
49
  request: Promise<T>
44
50
  /**
45
51
  * Abort the request.
@@ -56,13 +62,34 @@ export type ProcedureImplementation<
56
62
  P extends Type,
57
63
  S extends Type,
58
64
  > = (
65
+ /**
66
+ * Input data for the procedure
67
+ */
59
68
  input: I["inferOut"],
69
+ /**
70
+ * Callback to call with progress updates.
71
+ */
60
72
  onProgress: (progress: P["inferIn"]) => void,
61
- abortSignal?: AbortSignal
73
+ /**
74
+ * Additional tools useful when implementing the procedure.
75
+ */
76
+ tools: {
77
+ /**
78
+ * AbortSignal that can be used to handle request cancellation -- see [Make cancellable requests](https://gwennlbh.github.io/swarpc/docs/#make-cancelable-requests)
79
+ */
80
+ abortSignal?: AbortSignal
81
+ /**
82
+ * Logger instance to use for logging messages related to this procedure call, using the same format as SWARPC's built-in logging.
83
+ */
84
+ logger: RequestBoundLogger
85
+ }
62
86
  ) => Promise<S["inferIn"]>
63
87
 
64
88
  /**
65
89
  * Declarations of procedures by name.
90
+ *
91
+ * An example of declaring procedures:
92
+ * {@includeCode ../example/src/lib/procedures.ts}
66
93
  */
67
94
  export type ProceduresMap = Record<string, Procedure<Type, Type, Type>>
68
95
 
@@ -104,6 +131,9 @@ export type Hooks<Procedures extends ProceduresMap> = {
104
131
  ) => void
105
132
  }
106
133
 
134
+ /**
135
+ * @source
136
+ */
107
137
  export const PayloadHeaderSchema = type("<Name extends string>", {
108
138
  by: '"sw&rpc"',
109
139
  functionName: "Name",
@@ -119,6 +149,9 @@ export type PayloadHeader<
119
149
  requestId: string
120
150
  }
121
151
 
152
+ /**
153
+ * @source
154
+ */
122
155
  export const PayloadCoreSchema = type("<I, P, S>", {
123
156
  "input?": "I",
124
157
  "progress?": "P",
@@ -147,6 +180,9 @@ export type PayloadCore<
147
180
  error: { message: string }
148
181
  }
149
182
 
183
+ /**
184
+ * @source
185
+ */
150
186
  export const PayloadSchema = type
151
187
  .scope({ PayloadCoreSchema, PayloadHeaderSchema })
152
188
  .type("<Name extends string, I, P, S>", [
@@ -182,38 +218,14 @@ export type ClientMethod<P extends Procedure<Type, Type, Type>> = ((
182
218
 
183
219
  /**
184
220
  * Symbol used as the key for the procedures map on the server instance
221
+ * @internal
222
+ * @source
185
223
  */
186
224
  export const zImplementations = Symbol("SWARPC implementations")
225
+
187
226
  /**
188
227
  * Symbol used as the key for the procedures map on instances
228
+ * @internal
229
+ * @source
189
230
  */
190
231
  export const zProcedures = Symbol("SWARPC procedures")
191
-
192
- /**
193
- * The sw&rpc client instance, which provides methods to call procedures.
194
- * Each property of the procedures map will be a method, that accepts an input, an optional onProgress callback and an optional request ID.
195
- * If you want to be able to cancel the request, you can set the request's ID yourself, and call `.abort(requestId, reason)` on the client instance to cancel it.
196
- */
197
- export type SwarpcClient<Procedures extends ProceduresMap> = {
198
- [zProcedures]: Procedures
199
- } & {
200
- [F in keyof Procedures]: ClientMethod<Procedures[F]>
201
- }
202
-
203
- /**
204
- * The sw&rpc server instance, which provides methods to register procedure implementations,
205
- * and listens for incoming messages that call those procedures
206
- */
207
- export type SwarpcServer<Procedures extends ProceduresMap> = {
208
- [zProcedures]: Procedures
209
- [zImplementations]: ImplementationsMap<Procedures>
210
- start(self: Window | Worker): void
211
- } & {
212
- [F in keyof Procedures]: (
213
- impl: ProcedureImplementation<
214
- Procedures[F]["input"],
215
- Procedures[F]["progress"],
216
- Procedures[F]["success"]
217
- >
218
- ) => void
219
- }
@@ -1,22 +0,0 @@
1
- import { type LogLevel } from "./log.js";
2
- import { Hooks, type ProceduresMap, type SwarpcClient } from "./types.js";
3
- export type { SwarpcClient } from "./types.js";
4
- /**
5
- *
6
- * @param procedures procedures the client will be able to call
7
- * @param options various options
8
- * @param options.worker if provided, the client will use this worker to post messages.
9
- * @param options.hooks hooks to run on messages received from the server
10
- * @returns a sw&rpc client instance. Each property of the procedures map will be a method, that accepts an input and an optional onProgress callback.
11
- */
12
- export declare function Client<Procedures extends ProceduresMap>(procedures: Procedures, { worker, loglevel, hooks, }?: {
13
- worker?: Worker;
14
- hooks?: Hooks<Procedures>;
15
- loglevel?: LogLevel;
16
- }): SwarpcClient<Procedures>;
17
- /**
18
- * Generate a random request ID, used to identify requests between client and server.
19
- * @returns a 6-character hexadecimal string
20
- */
21
- export declare function makeRequestId(): string;
22
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnE,OAAO,EACL,KAAK,EAIL,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,YAAY,CAAA;AAGnB,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAkB9C;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,UAAU,SAAS,aAAa,EACrD,UAAU,EAAE,UAAU,EACtB,EACE,MAAM,EACN,QAAkB,EAClB,KAAU,GACX,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAAC,QAAQ,CAAC,EAAE,QAAQ,CAAA;CAAO,GAC1E,YAAY,CAAC,UAAU,CAAC,CA+F1B;AAmGD;;;GAGG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA"}
package/dist/src/log.d.ts DELETED
@@ -1,20 +0,0 @@
1
- export declare function createLogger(side: "server" | "client", level?: LogLevel): {
2
- debug: (rqid: string | null, message: string, ...args: any[]) => void;
3
- info: (rqid: string | null, message: string, ...args: any[]) => void;
4
- warn: (rqid: string | null, message: string, ...args: any[]) => void;
5
- error: (rqid: string | null, message: string, ...args: any[]) => void;
6
- };
7
- export type Logger = ReturnType<typeof createLogger>;
8
- declare const LOG_LEVELS: readonly ["debug", "info", "warn", "error"];
9
- export type LogLevel = (typeof LOG_LEVELS)[number];
10
- /**
11
- * Send log messages to the console, with a helpful prefix.
12
- * @param severity
13
- * @param side
14
- * @param rqid request ID
15
- * @param message
16
- * @param args passed to console methods directly
17
- */
18
- export declare function log(severity: "debug" | "info" | "warn" | "error", side: "server" | "client", rqid: string | null, message: string, ...args: any[]): void;
19
- export {};
20
- //# sourceMappingURL=log.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/log.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAC1B,IAAI,EAAE,QAAQ,GAAG,QAAQ,EACzB,KAAK,GAAE,QAAkB;kBAwBX,MAAM,GAAG,IAAI,WAAW,MAAM,WAAW,GAAG,EAAE;iBAA9C,MAAM,GAAG,IAAI,WAAW,MAAM,WAAW,GAAG,EAAE;iBAA9C,MAAM,GAAG,IAAI,WAAW,MAAM,WAAW,GAAG,EAAE;kBAA9C,MAAM,GAAG,IAAI,WAAW,MAAM,WAAW,GAAG,EAAE;EAd7D;AAED,MAAM,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAA;AAEpD,QAAA,MAAM,UAAU,6CAA8C,CAAA;AAC9D,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAA;AAalD;;;;;;;GAOG;AACH,wBAAgB,GAAG,CACjB,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,EAC7C,IAAI,EAAE,QAAQ,GAAG,QAAQ,EACzB,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,OAAO,EAAE,MAAM,EACf,GAAG,IAAI,EAAE,GAAG,EAAE,QAkBf"}
package/dist/src/log.js DELETED
@@ -1,45 +0,0 @@
1
- export function createLogger(side, level = "debug") {
2
- const enabledLevels = LOG_LEVELS.slice(LOG_LEVELS.indexOf(level));
3
- return {
4
- debug: enabledLevels.includes("debug") ? logger("debug", side) : () => { },
5
- info: enabledLevels.includes("info") ? logger("info", side) : () => { },
6
- warn: enabledLevels.includes("warn") ? logger("warn", side) : () => { },
7
- error: enabledLevels.includes("error") ? logger("error", side) : () => { },
8
- };
9
- }
10
- const LOG_LEVELS = ["debug", "info", "warn", "error"];
11
- /**
12
- * Creates partially-applied logging functions given the first 2 args
13
- * @param severity
14
- * @param side
15
- * @returns
16
- */
17
- function logger(severity, side) {
18
- return (rqid, message, ...args) => log(severity, side, rqid, message, ...args);
19
- }
20
- /**
21
- * Send log messages to the console, with a helpful prefix.
22
- * @param severity
23
- * @param side
24
- * @param rqid request ID
25
- * @param message
26
- * @param args passed to console methods directly
27
- */
28
- export function log(severity, side, rqid, message, ...args) {
29
- const prefix = "[" +
30
- ["SWARPC", side, rqid ? `%c${rqid}%c` : ""].filter(Boolean).join(" ") +
31
- "]";
32
- const prefixStyles = rqid ? ["color: cyan;", "color: inherit;"] : [];
33
- if (severity === "debug") {
34
- console.debug(prefix, ...prefixStyles, message, ...args);
35
- }
36
- else if (severity === "info") {
37
- console.info(prefix, ...prefixStyles, message, ...args);
38
- }
39
- else if (severity === "warn") {
40
- console.warn(prefix, ...prefixStyles, message, ...args);
41
- }
42
- else if (severity === "error") {
43
- console.error(prefix, ...prefixStyles, message, ...args);
44
- }
45
- }
@@ -1,15 +0,0 @@
1
- import { type LogLevel } from "./log.js";
2
- import { type ProceduresMap, type SwarpcServer } from "./types.js";
3
- export type { SwarpcServer } from "./types.js";
4
- /**
5
- * Creates a sw&rpc server instance.
6
- * @param procedures procedures the server will implement
7
- * @param options various options
8
- * @param options.worker if provided, the server will use this worker to post messages, instead of sending it to all clients
9
- * @returns a SwarpcServer instance. Each property of the procedures map will be a method, that accepts a function implementing the procedure. There is also .start(), to be called after implementing all procedures.
10
- */
11
- export declare function Server<Procedures extends ProceduresMap>(procedures: Procedures, { worker, loglevel }?: {
12
- worker?: Worker;
13
- loglevel?: LogLevel;
14
- }): SwarpcServer<Procedures>;
15
- //# sourceMappingURL=server.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,EAQL,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,YAAY,CAAA;AAGnB,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAK9C;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,UAAU,SAAS,aAAa,EACrD,UAAU,EAAE,UAAU,EACtB,EAAE,MAAM,EAAE,QAAkB,EAAE,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,QAAQ,CAAA;CAAO,GAC5E,YAAY,CAAC,UAAU,CAAC,CAkK1B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,IAAI,EAAE,MAAM,SAAS,CAAA;AAEzC;;GAEG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,SAAS,IAAI,EAAE,CAAC,SAAS,IAAI,IAAI;IACtE;;OAEG;IACH,KAAK,EAAE,CAAC,CAAA;IACR;;;OAGG;IACH,QAAQ,EAAE,CAAC,CAAA;IACX;;OAEG;IACH,OAAO,EAAE,CAAC,CAAA;IACV;;;;;;;;;OASG;IACH,YAAY,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,aAAa,CAAA;CAClD,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI;IACjC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;IACnB;;;OAGG;IACH,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,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,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;CACnC,GAAG;KACD,CAAC,IAAI,MAAM,UAAU,GAAG,CACvB,IAAI,EAAE,uBAAuB,CAC3B,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EACtB,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,EACzB,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CACzB,KACE,IAAI;CACV,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAWA,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,GAAG,YAAY,EAAE,CAsB5D"}
@@ -1,45 +0,0 @@
1
- export declare const procedures: {
2
- readonly hello: {
3
- readonly input: import("arktype/internal/methods/string.ts").StringType<string, {}>;
4
- readonly progress: import("arktype").BaseType<undefined, {}>;
5
- readonly success: import("arktype/internal/methods/string.ts").StringType<string, {}>;
6
- };
7
- readonly helloWithProgress: {
8
- readonly input: import("arktype/internal/methods/string.ts").StringType<string, {}>;
9
- readonly progress: import("arktype/internal/methods/object.ts").ObjectType<{
10
- current: number;
11
- total: number;
12
- }, {}>;
13
- readonly success: import("arktype/internal/methods/string.ts").StringType<string, {}>;
14
- };
15
- readonly cancellable: {
16
- readonly input: import("arktype/internal/methods/string.ts").StringType<string, {}>;
17
- readonly progress: import("arktype/internal/methods/object.ts").ObjectType<{
18
- current: number;
19
- total: number;
20
- }, {}>;
21
- readonly success: import("arktype/internal/methods/string.ts").StringType<string, {}>;
22
- };
23
- readonly complexData: {
24
- readonly input: import("arktype/internal/methods/object.ts").ObjectType<{
25
- name: string;
26
- age: number;
27
- custom: (In: string) => import("arktype/internal/attributes.ts").To<import("@ark/util").Json>;
28
- hobbies: import("arktype/internal/attributes.ts").Default<string[], never[]>;
29
- address: (In: {
30
- street: string;
31
- city: string;
32
- zip: string;
33
- houseno?: number | undefined;
34
- }) => import("arktype").Out<string>;
35
- }, {}>;
36
- readonly progress: import("arktype/internal/methods/object.ts").ObjectType<{
37
- message: string;
38
- percent: number;
39
- }, {}>;
40
- readonly success: import("arktype/internal/methods/object.ts").ObjectType<{
41
- message: string;
42
- }, {}>;
43
- };
44
- };
45
- //# sourceMappingURL=core.procedures.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core.procedures.d.ts","sourceRoot":"","sources":["../../tests/core.procedures.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDW,CAAA"}
@@ -1,49 +0,0 @@
1
- import { type } from "arktype";
2
- export const procedures = {
3
- hello: {
4
- input: type("string"),
5
- progress: type("undefined"),
6
- success: type("string"),
7
- },
8
- helloWithProgress: {
9
- input: type("string"),
10
- progress: type({
11
- current: "number",
12
- total: "number",
13
- }),
14
- success: type("string"),
15
- },
16
- cancellable: {
17
- input: type("string"),
18
- progress: type({
19
- current: "number",
20
- total: "number",
21
- }),
22
- success: type("string"),
23
- },
24
- complexData: {
25
- input: type({
26
- name: "string",
27
- age: "number",
28
- custom: "string.json.parse",
29
- hobbies: type("string[]").default(() => []),
30
- address: type([
31
- {
32
- "houseno?": "number",
33
- street: "string",
34
- city: "string",
35
- zip: "string",
36
- },
37
- "=>",
38
- (address) => `${address.houseno ? address.houseno + " " : ""}${address.street}, ${address.city} ${address.zip}`,
39
- ]),
40
- }),
41
- progress: type({
42
- message: "string",
43
- percent: "number",
44
- }),
45
- success: type({
46
- message: "string",
47
- }),
48
- },
49
- };
@@ -1,2 +0,0 @@
1
- import "@vitest/web-worker";
2
- //# sourceMappingURL=core.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core.test.d.ts","sourceRoot":"","sources":["../../tests/core.test.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAA"}