@go-mondo/identity-sdk 0.0.2-beta.48 → 0.0.2-beta.49

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.2-beta.49](https://github.com/go-mondo/identity-node-sdk/compare/identity-sdk-v0.0.2-beta.48...identity-sdk-v0.0.2-beta.49) (2025-12-06)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * pagination ([f10f276](https://github.com/go-mondo/identity-node-sdk/commit/f10f276add2cf8f75eecdbb388231c21804a33b6))
9
+
3
10
  ## [0.0.2-beta.48](https://github.com/go-mondo/identity-node-sdk/compare/identity-sdk-v0.0.2-beta.47...identity-sdk-v0.0.2-beta.48) (2025-12-02)
4
11
 
5
12
 
@@ -37,7 +37,7 @@ const utils_js_1 = require("./utils.js");
37
37
  (0, vitest_1.describe)('addPaginationToURL', () => {
38
38
  (0, vitest_1.test)('should add pagination params to URL', () => {
39
39
  const url = new URL('https://example.com/api');
40
- const pagination = { nextToken: 'token123', pageSize: '10' };
40
+ const pagination = { nextToken: 'token123', pageSize: 10 };
41
41
  const result = (0, utils_js_1.addPaginationToURL)(url, pagination);
42
42
  (0, vitest_1.expect)(result.searchParams.get('pagination[nextToken]')).toBe('token123');
43
43
  (0, vitest_1.expect)(result.searchParams.get('pagination[pageSize]')).toBe('10');
@@ -56,7 +56,7 @@ const utils_js_1 = require("./utils.js");
56
56
  });
57
57
  (0, vitest_1.test)('should not add params when values are null', () => {
58
58
  const url = new URL('https://example.com/api');
59
- const pagination = { nextToken: null, pageSize: null };
59
+ const pagination = {};
60
60
  const result = (0, utils_js_1.addPaginationToURL)(url, pagination);
61
61
  (0, vitest_1.expect)(result.searchParams.has('pagination[nextToken]')).toBe(false);
62
62
  (0, vitest_1.expect)(result.searchParams.has('pagination[pageSize]')).toBe(false);
@@ -1,5 +1,5 @@
1
1
  import * as z from 'zod/v4';
2
- import { type Pagination } from './pagination.js';
2
+ import { type PaginationPayload } from './pagination.js';
3
3
  export declare const CollectionSchema: <T extends z.ZodTypeAny>(itemSchema: T) => z.ZodObject<{
4
4
  items: z.ZodArray<T>;
5
5
  }, z.core.$strip>;
@@ -7,13 +7,11 @@ export type Collection<I> = {
7
7
  items: I[];
8
8
  };
9
9
  export declare const PaginationCollectionSchema: <T extends z.ZodTypeAny>(itemSchema: T) => z.ZodObject<{
10
- items: z.ZodArray<T>;
11
10
  pagination: z.ZodOptional<z.ZodObject<{
12
- pageSize: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>;
13
- nextToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
11
+ pageSize: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>, z.ZodTransform<number | undefined, string | number | null>>>;
12
+ nextToken: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>, z.ZodTransform<string | undefined, string | null>>>;
14
13
  }, z.core.$strip>>;
14
+ items: z.ZodArray<T>;
15
15
  }, z.core.$strip>;
16
- export type PaginationCollection<I> = Collection<I> & {
17
- pagination?: Pagination;
18
- };
16
+ export type PaginationCollection<I> = Collection<I> & PaginationPayload;
19
17
  //# sourceMappingURL=collection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../../../src/common/schema/collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,KAAK,UAAU,EAAoB,MAAM,iBAAiB,CAAC;AAEpE,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,YAAY,CAAC;;iBAC5B,CAAC;AAC3C,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAC1B,KAAK,EAAE,CAAC,EAAE,CAAC;CACZ,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAC/D,YAAY,CAAC;;;;;;iBAKX,CAAC;AACL,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG;IACpD,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,CAAC"}
1
+ {"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../../../src/common/schema/collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,KAAK,iBAAiB,EAAoB,MAAM,iBAAiB,CAAC;AAE3E,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,YAAY,CAAC;;iBAC5B,CAAC;AAC3C,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAC1B,KAAK,EAAE,CAAC,EAAE,CAAC;CACZ,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAC/D,YAAY,CAAC;;;;;;iBAKX,CAAC;AACL,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC"}
@@ -40,6 +40,6 @@ const CollectionSchema = (itemSchema) => z.object({ items: z.array(itemSchema) }
40
40
  exports.CollectionSchema = CollectionSchema;
41
41
  const PaginationCollectionSchema = (itemSchema) => z.object({
42
42
  items: z.array(itemSchema),
43
- pagination: pagination_js_1.PaginationSchema.optional(),
43
+ ...pagination_js_1.PaginationSchema.shape,
44
44
  });
45
45
  exports.PaginationCollectionSchema = PaginationCollectionSchema;
@@ -101,7 +101,7 @@ const collection_js_1 = require("./collection.js");
101
101
  (0, vitest_1.expect)(result.data).toEqual({
102
102
  items: ['item1', 'item2'],
103
103
  pagination: {
104
- pageSize: '10',
104
+ pageSize: 10,
105
105
  nextToken: 'token123',
106
106
  },
107
107
  });
@@ -1,7 +1,16 @@
1
1
  import * as z from 'zod/v4';
2
+ declare const PaginationPropertiesSchema: z.ZodObject<{
3
+ pageSize: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>, z.ZodTransform<number | undefined, string | number | null>>>;
4
+ nextToken: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>, z.ZodTransform<string | undefined, string | null>>>;
5
+ }, z.core.$strip>;
6
+ export type Pagination = z.output<typeof PaginationPropertiesSchema>;
2
7
  export declare const PaginationSchema: z.ZodObject<{
3
- pageSize: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>;
4
- nextToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
8
+ pagination: z.ZodOptional<z.ZodObject<{
9
+ pageSize: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>, z.ZodTransform<number | undefined, string | number | null>>>;
10
+ nextToken: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>, z.ZodTransform<string | undefined, string | null>>>;
11
+ }, z.core.$strip>>;
5
12
  }, z.core.$strip>;
6
- export type Pagination = z.output<typeof PaginationSchema>;
13
+ export type PaginationInput = z.input<typeof PaginationSchema>;
14
+ export type PaginationPayload = z.output<typeof PaginationSchema>;
15
+ export {};
7
16
  //# sourceMappingURL=pagination.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../../src/common/schema/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,eAAO,MAAM,gBAAgB;;;iBAG3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
1
+ {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../../src/common/schema/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,QAAA,MAAM,0BAA0B;;;iBAS9B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAErE,eAAO,MAAM,gBAAgB;;;;;iBAE3B,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC/D,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
@@ -35,7 +35,16 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.PaginationSchema = void 0;
37
37
  const z = __importStar(require("zod/v4"));
38
+ const PaginationPropertiesSchema = z.object({
39
+ pageSize: z
40
+ .union([z.string(), z.number(), z.null()])
41
+ .pipe(z.transform((v) => (v ? Number(v) : undefined)))
42
+ .optional(),
43
+ nextToken: z
44
+ .union([z.string(), z.null()])
45
+ .pipe(z.transform((v) => v || undefined))
46
+ .optional(),
47
+ });
38
48
  exports.PaginationSchema = z.object({
39
- pageSize: z.union([z.string(), z.number(), z.null()]).optional(),
40
- nextToken: z.union([z.string(), z.null()]).optional(),
49
+ pagination: PaginationPropertiesSchema.optional(),
41
50
  });
@@ -6,42 +6,58 @@ const pagination_js_1 = require("./pagination.js");
6
6
  (0, vitest_1.describe)('PaginationSchema', () => {
7
7
  (0, vitest_1.test)('should accept valid pagination with pageSize as string', () => {
8
8
  const result = pagination_js_1.PaginationSchema.safeParse({
9
- pageSize: '10',
10
- nextToken: 'token123',
9
+ pagination: {
10
+ pageSize: '10',
11
+ nextToken: 'token123',
12
+ },
11
13
  });
12
14
  // Parse succeeds for valid data
13
15
  (0, vitest_1.expect)(result.data).toEqual({
14
- pageSize: '10',
15
- nextToken: 'token123',
16
+ pagination: {
17
+ pageSize: 10,
18
+ nextToken: 'token123',
19
+ },
16
20
  });
17
21
  });
18
22
  (0, vitest_1.test)('should accept valid pagination with pageSize as number', () => {
19
23
  const result = pagination_js_1.PaginationSchema.safeParse({
20
- pageSize: 20,
21
- nextToken: 'token456',
24
+ pagination: {
25
+ pageSize: 20,
26
+ nextToken: 'token456',
27
+ },
22
28
  });
23
29
  // Parse succeeds for valid data
24
30
  (0, vitest_1.expect)(result.data).toEqual({
25
- pageSize: 20,
26
- nextToken: 'token456',
31
+ pagination: {
32
+ pageSize: 20,
33
+ nextToken: 'token456',
34
+ },
27
35
  });
28
36
  });
29
37
  (0, vitest_1.test)('should accept pagination with only pageSize', () => {
30
38
  const result = pagination_js_1.PaginationSchema.safeParse({
31
- pageSize: '15',
39
+ pagination: {
40
+ pageSize: '15',
41
+ },
32
42
  });
33
43
  // Parse succeeds for valid data
34
44
  (0, vitest_1.expect)(result.data).toEqual({
35
- pageSize: '15',
45
+ pagination: {
46
+ pageSize: 15,
47
+ },
36
48
  });
37
49
  });
38
50
  (0, vitest_1.test)('should accept pagination with only nextToken', () => {
39
51
  const result = pagination_js_1.PaginationSchema.safeParse({
40
- nextToken: 'token789',
52
+ pagination: {
53
+ nextToken: 'token789',
54
+ },
41
55
  });
42
56
  // Parse succeeds for valid data
43
57
  (0, vitest_1.expect)(result.data).toEqual({
44
- nextToken: 'token789',
58
+ pagination: {
59
+ nextToken: 'token789',
60
+ },
45
61
  });
46
62
  });
47
63
  (0, vitest_1.test)('should accept empty pagination object', () => {
@@ -51,15 +67,19 @@ const pagination_js_1 = require("./pagination.js");
51
67
  });
52
68
  (0, vitest_1.test)('should reject invalid pageSize type', () => {
53
69
  const result = pagination_js_1.PaginationSchema.safeParse({
54
- pageSize: true,
55
- nextToken: 'token123',
70
+ pagination: {
71
+ pageSize: true,
72
+ nextToken: 'token123',
73
+ },
56
74
  });
57
75
  (0, vitest_1.expect)(result.success).toBe(false);
58
76
  });
59
77
  (0, vitest_1.test)('should reject invalid nextToken type', () => {
60
78
  const result = pagination_js_1.PaginationSchema.safeParse({
61
- pageSize: '10',
62
- nextToken: 123,
79
+ pagination: {
80
+ pageSize: 10,
81
+ nextToken: 123,
82
+ },
63
83
  });
64
84
  (0, vitest_1.expect)(result.success).toBe(false);
65
85
  });
@@ -35,7 +35,7 @@ describe('Common Resources - Utils', () => {
35
35
  describe('addPaginationToURL', () => {
36
36
  test('should add pagination params to URL', () => {
37
37
  const url = new URL('https://example.com/api');
38
- const pagination = { nextToken: 'token123', pageSize: '10' };
38
+ const pagination = { nextToken: 'token123', pageSize: 10 };
39
39
  const result = addPaginationToURL(url, pagination);
40
40
  expect(result.searchParams.get('pagination[nextToken]')).toBe('token123');
41
41
  expect(result.searchParams.get('pagination[pageSize]')).toBe('10');
@@ -54,7 +54,7 @@ describe('Common Resources - Utils', () => {
54
54
  });
55
55
  test('should not add params when values are null', () => {
56
56
  const url = new URL('https://example.com/api');
57
- const pagination = { nextToken: null, pageSize: null };
57
+ const pagination = {};
58
58
  const result = addPaginationToURL(url, pagination);
59
59
  expect(result.searchParams.has('pagination[nextToken]')).toBe(false);
60
60
  expect(result.searchParams.has('pagination[pageSize]')).toBe(false);
@@ -1,5 +1,5 @@
1
1
  import * as z from 'zod/v4';
2
- import { type Pagination } from './pagination.js';
2
+ import { type PaginationPayload } from './pagination.js';
3
3
  export declare const CollectionSchema: <T extends z.ZodTypeAny>(itemSchema: T) => z.ZodObject<{
4
4
  items: z.ZodArray<T>;
5
5
  }, z.core.$strip>;
@@ -7,13 +7,11 @@ export type Collection<I> = {
7
7
  items: I[];
8
8
  };
9
9
  export declare const PaginationCollectionSchema: <T extends z.ZodTypeAny>(itemSchema: T) => z.ZodObject<{
10
- items: z.ZodArray<T>;
11
10
  pagination: z.ZodOptional<z.ZodObject<{
12
- pageSize: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>;
13
- nextToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
11
+ pageSize: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>, z.ZodTransform<number | undefined, string | number | null>>>;
12
+ nextToken: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>, z.ZodTransform<string | undefined, string | null>>>;
14
13
  }, z.core.$strip>>;
14
+ items: z.ZodArray<T>;
15
15
  }, z.core.$strip>;
16
- export type PaginationCollection<I> = Collection<I> & {
17
- pagination?: Pagination;
18
- };
16
+ export type PaginationCollection<I> = Collection<I> & PaginationPayload;
19
17
  //# sourceMappingURL=collection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../../../src/common/schema/collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,KAAK,UAAU,EAAoB,MAAM,iBAAiB,CAAC;AAEpE,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,YAAY,CAAC;;iBAC5B,CAAC;AAC3C,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAC1B,KAAK,EAAE,CAAC,EAAE,CAAC;CACZ,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAC/D,YAAY,CAAC;;;;;;iBAKX,CAAC;AACL,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG;IACpD,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,CAAC"}
1
+ {"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../../../src/common/schema/collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,KAAK,iBAAiB,EAAoB,MAAM,iBAAiB,CAAC;AAE3E,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,YAAY,CAAC;;iBAC5B,CAAC;AAC3C,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAC1B,KAAK,EAAE,CAAC,EAAE,CAAC;CACZ,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAC/D,YAAY,CAAC;;;;;;iBAKX,CAAC;AACL,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC"}
@@ -3,5 +3,5 @@ import { PaginationSchema } from './pagination.js';
3
3
  export const CollectionSchema = (itemSchema) => z.object({ items: z.array(itemSchema) });
4
4
  export const PaginationCollectionSchema = (itemSchema) => z.object({
5
5
  items: z.array(itemSchema),
6
- pagination: PaginationSchema.optional(),
6
+ ...PaginationSchema.shape,
7
7
  });
@@ -66,7 +66,7 @@ describe('Common Schema - Collection', () => {
66
66
  expect(result.data).toEqual({
67
67
  items: ['item1', 'item2'],
68
68
  pagination: {
69
- pageSize: '10',
69
+ pageSize: 10,
70
70
  nextToken: 'token123',
71
71
  },
72
72
  });
@@ -1,7 +1,16 @@
1
1
  import * as z from 'zod/v4';
2
+ declare const PaginationPropertiesSchema: z.ZodObject<{
3
+ pageSize: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>, z.ZodTransform<number | undefined, string | number | null>>>;
4
+ nextToken: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>, z.ZodTransform<string | undefined, string | null>>>;
5
+ }, z.core.$strip>;
6
+ export type Pagination = z.output<typeof PaginationPropertiesSchema>;
2
7
  export declare const PaginationSchema: z.ZodObject<{
3
- pageSize: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>;
4
- nextToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
8
+ pagination: z.ZodOptional<z.ZodObject<{
9
+ pageSize: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>, z.ZodTransform<number | undefined, string | number | null>>>;
10
+ nextToken: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>, z.ZodTransform<string | undefined, string | null>>>;
11
+ }, z.core.$strip>>;
5
12
  }, z.core.$strip>;
6
- export type Pagination = z.output<typeof PaginationSchema>;
13
+ export type PaginationInput = z.input<typeof PaginationSchema>;
14
+ export type PaginationPayload = z.output<typeof PaginationSchema>;
15
+ export {};
7
16
  //# sourceMappingURL=pagination.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../../src/common/schema/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,eAAO,MAAM,gBAAgB;;;iBAG3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
1
+ {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../../src/common/schema/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,QAAA,MAAM,0BAA0B;;;iBAS9B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAErE,eAAO,MAAM,gBAAgB;;;;;iBAE3B,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC/D,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
@@ -1,5 +1,14 @@
1
1
  import * as z from 'zod/v4';
2
+ const PaginationPropertiesSchema = z.object({
3
+ pageSize: z
4
+ .union([z.string(), z.number(), z.null()])
5
+ .pipe(z.transform((v) => (v ? Number(v) : undefined)))
6
+ .optional(),
7
+ nextToken: z
8
+ .union([z.string(), z.null()])
9
+ .pipe(z.transform((v) => v || undefined))
10
+ .optional(),
11
+ });
2
12
  export const PaginationSchema = z.object({
3
- pageSize: z.union([z.string(), z.number(), z.null()]).optional(),
4
- nextToken: z.union([z.string(), z.null()]).optional(),
13
+ pagination: PaginationPropertiesSchema.optional(),
5
14
  });
@@ -4,42 +4,58 @@ describe('Common Schema - Pagination', () => {
4
4
  describe('PaginationSchema', () => {
5
5
  test('should accept valid pagination with pageSize as string', () => {
6
6
  const result = PaginationSchema.safeParse({
7
- pageSize: '10',
8
- nextToken: 'token123',
7
+ pagination: {
8
+ pageSize: '10',
9
+ nextToken: 'token123',
10
+ },
9
11
  });
10
12
  // Parse succeeds for valid data
11
13
  expect(result.data).toEqual({
12
- pageSize: '10',
13
- nextToken: 'token123',
14
+ pagination: {
15
+ pageSize: 10,
16
+ nextToken: 'token123',
17
+ },
14
18
  });
15
19
  });
16
20
  test('should accept valid pagination with pageSize as number', () => {
17
21
  const result = PaginationSchema.safeParse({
18
- pageSize: 20,
19
- nextToken: 'token456',
22
+ pagination: {
23
+ pageSize: 20,
24
+ nextToken: 'token456',
25
+ },
20
26
  });
21
27
  // Parse succeeds for valid data
22
28
  expect(result.data).toEqual({
23
- pageSize: 20,
24
- nextToken: 'token456',
29
+ pagination: {
30
+ pageSize: 20,
31
+ nextToken: 'token456',
32
+ },
25
33
  });
26
34
  });
27
35
  test('should accept pagination with only pageSize', () => {
28
36
  const result = PaginationSchema.safeParse({
29
- pageSize: '15',
37
+ pagination: {
38
+ pageSize: '15',
39
+ },
30
40
  });
31
41
  // Parse succeeds for valid data
32
42
  expect(result.data).toEqual({
33
- pageSize: '15',
43
+ pagination: {
44
+ pageSize: 15,
45
+ },
34
46
  });
35
47
  });
36
48
  test('should accept pagination with only nextToken', () => {
37
49
  const result = PaginationSchema.safeParse({
38
- nextToken: 'token789',
50
+ pagination: {
51
+ nextToken: 'token789',
52
+ },
39
53
  });
40
54
  // Parse succeeds for valid data
41
55
  expect(result.data).toEqual({
42
- nextToken: 'token789',
56
+ pagination: {
57
+ nextToken: 'token789',
58
+ },
43
59
  });
44
60
  });
45
61
  test('should accept empty pagination object', () => {
@@ -49,15 +65,19 @@ describe('Common Schema - Pagination', () => {
49
65
  });
50
66
  test('should reject invalid pageSize type', () => {
51
67
  const result = PaginationSchema.safeParse({
52
- pageSize: true,
53
- nextToken: 'token123',
68
+ pagination: {
69
+ pageSize: true,
70
+ nextToken: 'token123',
71
+ },
54
72
  });
55
73
  expect(result.success).toBe(false);
56
74
  });
57
75
  test('should reject invalid nextToken type', () => {
58
76
  const result = PaginationSchema.safeParse({
59
- pageSize: '10',
60
- nextToken: 123,
77
+ pagination: {
78
+ pageSize: 10,
79
+ nextToken: 123,
80
+ },
61
81
  });
62
82
  expect(result.success).toBe(false);
63
83
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-mondo/identity-sdk",
3
- "version": "0.0.2-beta.48",
3
+ "version": "0.0.2-beta.49",
4
4
  "type": "module",
5
5
  "description": "A node SDK for Mondo Identity",
6
6
  "license": "MIT",