@danypops/papyrus 0.44.9 → 0.44.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/service.ts CHANGED
@@ -25,6 +25,7 @@ import { DOCS_OPERATION_NAMES, docsOperations } from "./modules/docs.ts";
25
25
  import { GRAPH_PROJECTION_OPERATION_NAMES, graphProjectionOperations } from "./modules/graph-projection.ts";
26
26
  import { LOGS_OPERATION_NAMES, logsOperations } from "./modules/logs.ts";
27
27
  import { NOTES_OPERATION_NAMES, notesOperations } from "./modules/notes.ts";
28
+ import { type OperationInput, optionalNumber, optionalString, string } from "./modules/operation-input.ts";
28
29
  import { PLAYBOOKS_OPERATION_NAMES, playbooksOperations } from "./modules/playbooks.ts";
29
30
  import { RULES_OPERATION_NAMES, rulesOperations } from "./modules/rules.ts";
30
31
  import { SESSION_IDENTITY_OPERATION_NAMES, sessionIdentityOperations } from "./modules/session-identity.ts";
@@ -99,7 +100,6 @@ export const EXPECTED_OPERATION_NAMES = [
99
100
  ] as const;
100
101
 
101
102
  export type OperationName = (typeof EXPECTED_OPERATION_NAMES)[number];
102
- type OperationInput = Record<string, unknown>;
103
103
  type OperationHandler = (input: OperationInput) => unknown;
104
104
 
105
105
  export class UnknownOperationError extends Error {}
@@ -107,33 +107,6 @@ export class MigrationRequiredError extends Error {}
107
107
  export class PayloadTooLargeError extends Error {}
108
108
  export { InvalidSessionSecretError };
109
109
 
110
- function string(input: OperationInput, key: string): string {
111
- const value = input[key];
112
- if (typeof value !== "string" || value.length === 0) throw new Error(`${key} is required`);
113
- return value;
114
- }
115
-
116
- function optionalString(input: OperationInput, key: string): string | undefined {
117
- const value = input[key];
118
- if (value === undefined) return undefined;
119
- if (typeof value !== "string") throw new Error(`${key} must be a string`);
120
- return value;
121
- }
122
-
123
- function _optionalStringArray(input: OperationInput, key: string): string[] | undefined {
124
- const value = input[key];
125
- if (value === undefined) return undefined;
126
- if (!Array.isArray(value) || value.some((entry) => typeof entry !== "string")) throw new Error(`${key} must be an array of strings`);
127
- return value as string[];
128
- }
129
-
130
- function optionalNumber(input: OperationInput, key: string): number | undefined {
131
- const value = input[key];
132
- if (value === undefined) return undefined;
133
- if (typeof value !== "number" || !Number.isFinite(value)) throw new Error(`${key} must be a number`);
134
- return value;
135
- }
136
-
137
110
  function normalizeCreateInput(input: OperationInput): CreateArtifactInput {
138
111
  const { template_id, ...rest } = input;
139
112
  return { ...rest, templateId: typeof template_id === "string" ? template_id : undefined } as CreateArtifactInput;