@apify/actor-utils 0.1.9-beta.1 → 0.1.9-beta.2

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.
@@ -1,2 +1,3 @@
1
1
  export { partialSafeParse, PartialSafeParseResult, RecursivePartial } from './partial-safe-parse.js';
2
+ export { StringyIntegerSchema } from './stringy-integer-schema.js';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/zod/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/zod/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export { partialSafeParse } from './partial-safe-parse.js';
2
+ export { StringyIntegerSchema } from './stringy-integer-schema.js';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/zod/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA4C,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/zod/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA4C,MAAM,yBAAyB,CAAC;AACrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * This validates the string is a plain non-negative integer and converts it to a `number`.
4
+ * - Also rejects values that would lose precision past `Number.MAX_SAFE_INTEGER`
5
+ */
6
+ export declare const StringyIntegerSchema: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
7
+ //# sourceMappingURL=stringy-integer-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringy-integer-schema.d.ts","sourceRoot":"","sources":["../../../src/zod/stringy-integer-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,oBAAoB,wDAgB3B,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * This validates the string is a plain non-negative integer and converts it to a `number`.
4
+ * - Also rejects values that would lose precision past `Number.MAX_SAFE_INTEGER`
5
+ */
6
+ export const StringyIntegerSchema = z
7
+ .string()
8
+ .regex(/^\d+$/, {
9
+ error: (issue) => `Invalid input: expected numeric string, received ${JSON.stringify(issue.input)}`,
10
+ })
11
+ .transform((value, ctx) => {
12
+ const number = Number(value);
13
+ if (Number.isSafeInteger(number))
14
+ return number;
15
+ ctx.addIssue({
16
+ code: 'custom',
17
+ message: `Invalid input: stringy integer "${value}" exceeds Number.MAX_SAFE_INTEGER and would lose precision` +
18
+ ' - use z.string() for this field instead',
19
+ });
20
+ return z.NEVER;
21
+ });
22
+ //# sourceMappingURL=stringy-integer-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringy-integer-schema.js","sourceRoot":"","sources":["../../../src/zod/stringy-integer-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC;KAChC,MAAM,EAAE;KACR,KAAK,CAAC,OAAO,EAAE;IACZ,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,oDAAoD,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;CACtG,CAAC;KACD,SAAS,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACtB,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAEhD,GAAG,CAAC,QAAQ,CAAC;QACT,IAAI,EAAE,QAAQ;QACd,OAAO,EACH,mCAAmC,KAAK,4DAA4D;YACpG,0CAA0C;KACjD,CAAC,CAAC;IACH,OAAO,CAAC,CAAC,KAAK,CAAC;AACnB,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apify/actor-utils",
3
- "version": "0.1.9-beta.1",
3
+ "version": "0.1.9-beta.2",
4
4
  "type": "module",
5
5
  "description": "Wrapper around Actor.pushData that survives dataset schema-validation failures by stripping offending fields and retrying. Callers pass the actual push function as pushFn.",
6
6
  "repository": {