@peable.to/contracts 0.2.1 → 0.4.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.
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.contributionPatchSchema = exports.contributionOperationKeySchema = exports.contributionMintSchema = exports.contributionPageQuerySchema = exports.contributionCollectionListSchema = exports.contributionCollectionSchema = exports.contributionListSchema = exports.contributionLinkSchema = exports.createContributionSchema = exports.contributionDetailsSchema = exports.contributionAmountSchema = void 0;
3
+ exports.contributionPatchSchema = exports.contributionOperationKeySchema = exports.contributionMintSchema = exports.contributionPageQuerySchema = exports.listQueryShape = exports.contributionCollectionListSchema = exports.contributionCollectionSchema = exports.contributionListSchema = exports.contributionLinkSchema = exports.createContributionSchema = exports.contributionDetailsSchema = exports.contributionAmountSchema = void 0;
4
4
  exports.decimalContributionAmount = decimalContributionAmount;
5
5
  exports.formatContributionAmount = formatContributionAmount;
6
6
  const zod_1 = require("zod");
@@ -8,67 +8,119 @@ exports.contributionAmountSchema = zod_1.z
8
8
  .string()
9
9
  .regex(/^[1-9][0-9]{0,15}$/)
10
10
  .refine((v) => /^[1-9][0-9]{0,15}$/.test(v) && BigInt(v) <= 9007199254740991n, 'Enter a positive FairCoin base-unit amount within the supported range');
11
+ /** Every instant on the wire is integer Unix seconds (ADR 0014 D1). */
12
+ const unixSecondsSchema = zod_1.z.number().int().nonnegative();
11
13
  exports.contributionDetailsSchema = zod_1.z
12
14
  .object({
13
- organizationId: zod_1.z.string().min(1).max(200),
15
+ organization_id: zod_1.z.string().min(1).max(200),
14
16
  purpose: zod_1.z.string().trim().min(1).max(500),
15
- amountMode: zod_1.z.enum(['fixed', 'free']),
16
- expiresAt: zod_1.z.iso.datetime().nullable(),
17
+ amount_mode: zod_1.z.enum(['fixed', 'free']),
18
+ expires_at: unixSecondsSchema.nullable(),
17
19
  })
18
20
  .strict();
19
21
  exports.createContributionSchema = zod_1.z
20
22
  .object({
21
23
  purpose: exports.contributionDetailsSchema.shape.purpose,
22
- amountMode: exports.contributionDetailsSchema.shape.amountMode,
24
+ amount_mode: exports.contributionDetailsSchema.shape.amount_mode,
23
25
  amount: exports.contributionAmountSchema.optional(),
24
26
  currency: zod_1.z.literal('FAIR'),
25
- expiresAt: zod_1.z.iso.datetime().nullable().optional(),
27
+ expires_at: unixSecondsSchema.nullable().optional(),
26
28
  })
27
29
  .strict()
28
- .refine((v) => (v.amountMode === 'free' ? v.amount === undefined : v.amount !== undefined), 'Fixed contributions require an amount; free contributions omit it');
30
+ .refine((v) => (v.amount_mode === 'free' ? v.amount === undefined : v.amount !== undefined), 'Fixed contributions require an amount; free contributions omit it');
29
31
  exports.contributionLinkSchema = zod_1.z
30
32
  .object({
31
33
  id: zod_1.z.string(),
34
+ object: zod_1.z.literal('payment_link'),
32
35
  amount: zod_1.z.string(),
33
36
  currency: zod_1.z.literal('FAIR'),
34
37
  network: zod_1.z.enum(['mainnet', 'testnet']),
35
38
  active: zod_1.z.boolean(),
36
39
  url: zod_1.z.url(),
37
40
  contribution: exports.contributionDetailsSchema,
38
- createdAt: zod_1.z.iso.datetime(),
41
+ created: unixSecondsSchema,
39
42
  })
40
43
  .strict();
41
- exports.contributionListSchema = zod_1.z
42
- .object({ items: zod_1.z.array(exports.contributionLinkSchema), nextCursor: zod_1.z.string().nullable() })
43
- .strict();
44
+ /**
45
+ * The one list envelope (ADR 0014 D1): `url` is the path that was listed.
46
+ */
47
+ function listSchema(item) {
48
+ return zod_1.z
49
+ .object({
50
+ object: zod_1.z.literal('list'),
51
+ data: zod_1.z.array(item),
52
+ has_more: zod_1.z.boolean(),
53
+ url: zod_1.z.string(),
54
+ })
55
+ .strict();
56
+ }
57
+ exports.contributionListSchema = listSchema(exports.contributionLinkSchema);
44
58
  exports.contributionCollectionSchema = zod_1.z
45
59
  .object({
46
60
  id: zod_1.z.string(),
61
+ object: zod_1.z.literal('payment_intent'),
47
62
  amount: zod_1.z.string(),
48
63
  currency: zod_1.z.literal('FAIR'),
49
64
  status: zod_1.z.string(),
50
- createdAt: zod_1.z.iso.datetime(),
51
- refundCapability: zod_1.z.literal('unsupported_non_custodial'),
65
+ created: unixSecondsSchema,
66
+ refund_capability: zod_1.z.literal('unsupported_non_custodial'),
52
67
  refunds: zod_1.z.array(zod_1.z
53
68
  .object({
54
69
  id: zod_1.z.string(),
70
+ object: zod_1.z.literal('refund'),
55
71
  amount: zod_1.z.string(),
56
72
  status: zod_1.z.string(),
57
- createdAt: zod_1.z.iso.datetime(),
73
+ created: unixSecondsSchema,
58
74
  })
59
75
  .strict()),
60
76
  })
61
77
  .strict();
62
- exports.contributionCollectionListSchema = zod_1.z
63
- .object({ items: zod_1.z.array(exports.contributionCollectionSchema), nextCursor: zod_1.z.string().nullable() })
64
- .strict();
78
+ exports.contributionCollectionListSchema = listSchema(exports.contributionCollectionSchema);
79
+ const unixSecondsQuery = zod_1.z.coerce.number().int().nonnegative();
80
+ /**
81
+ * The list parameters every list accepts (ADR 0014 D1), newest first:
82
+ *
83
+ * - `limit` 1–100, default 10;
84
+ * - `starting_after` — the id of the last object of the previous page — or
85
+ * `ending_before` — the id of the first object of the current one, which
86
+ * pages backwards and still answers newest first. Never both;
87
+ * - `created` (one second) or `created[gt|gte|lt|lte]`, Unix seconds.
88
+ *
89
+ * Cursors are resolved by the gateway inside the caller's scope; one naming
90
+ * anything else is a 400 with `param` naming the cursor.
91
+ */
92
+ exports.listQueryShape = {
93
+ limit: zod_1.z.coerce.number().int().min(1).max(100).default(10),
94
+ starting_after: zod_1.z.string().min(1).max(255).optional(),
95
+ ending_before: zod_1.z.string().min(1).max(255).optional(),
96
+ created: zod_1.z
97
+ .union([
98
+ unixSecondsQuery.transform((x) => ({ gte: x, lte: x })),
99
+ zod_1.z
100
+ .object({
101
+ gt: unixSecondsQuery.optional(),
102
+ gte: unixSecondsQuery.optional(),
103
+ lt: unixSecondsQuery.optional(),
104
+ lte: unixSecondsQuery.optional(),
105
+ })
106
+ .strict(),
107
+ ])
108
+ .optional(),
109
+ };
110
+ /**
111
+ * Paging a contribution list: the list parameters (`link_…` cursors for links,
112
+ * `pi_…` for collections) plus the environment the Test/Live toggle selects.
113
+ */
65
114
  exports.contributionPageQuerySchema = zod_1.z
66
115
  .object({
67
- limit: zod_1.z.coerce.number().int().min(1).max(100).default(20),
68
- cursor: zod_1.z.string().max(1000).optional(),
116
+ ...exports.listQueryShape,
69
117
  environment: zod_1.z.enum(['development', 'staging', 'production']),
70
118
  })
71
- .strict();
119
+ .strict()
120
+ .refine((query) => query.starting_after === undefined || query.ending_before === undefined, {
121
+ message: 'starting_after and ending_before are mutually exclusive',
122
+ path: ['ending_before'],
123
+ });
72
124
  exports.contributionMintSchema = zod_1.z
73
125
  .object({ amount: exports.contributionAmountSchema.optional() })
74
126
  .strict();
@@ -4,12 +4,19 @@ exports.contributionRoutes = void 0;
4
4
  exports.contributionOpenApi = contributionOpenApi;
5
5
  const zod_1 = require("zod");
6
6
  const index_1 = require("./index");
7
+ const requestIdHeader = {
8
+ 'Request-Id': {
9
+ description: 'Identifies this request to Peable support.',
10
+ schema: { type: 'string' },
11
+ },
12
+ };
7
13
  const path = '/v1/organizations/{organizationId}/applications/{applicationId}/contributions';
8
14
  exports.contributionRoutes = [
9
15
  {
10
16
  method: 'post',
11
17
  path,
12
18
  operationId: 'createContribution',
19
+ idempotencyKey: true,
13
20
  body: index_1.createContributionSchema,
14
21
  response: index_1.contributionLinkSchema,
15
22
  status: 201,
@@ -22,7 +29,7 @@ exports.contributionRoutes = [
22
29
  status: 200,
23
30
  },
24
31
  {
25
- method: 'patch',
32
+ method: 'post',
26
33
  path: `${path}/{id}`,
27
34
  operationId: 'setContributionActive',
28
35
  body: index_1.contributionPatchSchema,
@@ -58,9 +65,40 @@ function contributionOpenApi() {
58
65
  parameters.push({
59
66
  in: 'query',
60
67
  name: 'limit',
61
- schema: { type: 'integer', minimum: 1, maximum: 100, default: 20 },
62
- }, { in: 'query', name: 'cursor', schema: { type: 'string' } });
63
- if (route.method === 'post')
68
+ schema: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
69
+ }, {
70
+ in: 'query',
71
+ name: 'starting_after',
72
+ description: 'The id of the last object on the previous page.',
73
+ schema: { type: 'string' },
74
+ }, {
75
+ in: 'query',
76
+ name: 'ending_before',
77
+ description: 'The id of the first object on the current page; pages backwards, newest first.',
78
+ schema: { type: 'string' },
79
+ }, {
80
+ in: 'query',
81
+ name: 'created',
82
+ description: 'Unix seconds: one second, or `created[gt|gte|lt|lte]`.',
83
+ style: 'deepObject',
84
+ explode: true,
85
+ schema: {
86
+ oneOf: [
87
+ { type: 'integer', minimum: 0 },
88
+ {
89
+ type: 'object',
90
+ additionalProperties: false,
91
+ properties: {
92
+ gt: { type: 'integer', minimum: 0 },
93
+ gte: { type: 'integer', minimum: 0 },
94
+ lt: { type: 'integer', minimum: 0 },
95
+ lte: { type: 'integer', minimum: 0 },
96
+ },
97
+ },
98
+ ],
99
+ },
100
+ });
101
+ if ('idempotencyKey' in route)
64
102
  parameters.push({
65
103
  in: 'header',
66
104
  name: 'Idempotency-Key',
@@ -82,10 +120,12 @@ function contributionOpenApi() {
82
120
  responses: {
83
121
  [route.status]: {
84
122
  description: 'Success',
123
+ headers: requestIdHeader,
85
124
  content: { 'application/json': { schema: zod_1.z.toJSONSchema(route.response) } },
86
125
  },
87
126
  default: {
88
127
  description: 'Peable error envelope; HTTP status identifies failure',
128
+ headers: requestIdHeader,
89
129
  content: {
90
130
  'application/json': {
91
131
  schema: {
@@ -94,8 +134,14 @@ function contributionOpenApi() {
94
134
  properties: {
95
135
  error: {
96
136
  type: 'object',
97
- required: ['type', 'message'],
98
- properties: { type: { type: 'string' }, message: { type: 'string' } },
137
+ required: ['type', 'message', 'request_id'],
138
+ properties: {
139
+ type: { type: 'string' },
140
+ code: { type: 'string' },
141
+ param: { type: 'string' },
142
+ message: { type: 'string' },
143
+ request_id: { type: ['string', 'null'] },
144
+ },
99
145
  },
100
146
  },
101
147
  },
@@ -109,7 +155,7 @@ function contributionOpenApi() {
109
155
  openapi: '3.1.0',
110
156
  info: {
111
157
  title: 'Peable organization contributions',
112
- version: '0.1.0',
158
+ version: '0.2.0',
113
159
  description: 'One-off links. Human Oxy session for management; existing /v1/payment_links/{id}/public and /payment_intent remain anonymous. Fixed/free amounts use FAIR base units (8 decimals); the registered merchant determines the network. Refunds cannot be created by the watch-only gateway. No recurring billing.',
114
160
  },
115
161
  servers: [{ url: 'https://api.peable.to' }],
package/dist/esm/index.js CHANGED
@@ -3,67 +3,119 @@ export const contributionAmountSchema = z
3
3
  .string()
4
4
  .regex(/^[1-9][0-9]{0,15}$/)
5
5
  .refine((v) => /^[1-9][0-9]{0,15}$/.test(v) && BigInt(v) <= 9007199254740991n, 'Enter a positive FairCoin base-unit amount within the supported range');
6
+ /** Every instant on the wire is integer Unix seconds (ADR 0014 D1). */
7
+ const unixSecondsSchema = z.number().int().nonnegative();
6
8
  export const contributionDetailsSchema = z
7
9
  .object({
8
- organizationId: z.string().min(1).max(200),
10
+ organization_id: z.string().min(1).max(200),
9
11
  purpose: z.string().trim().min(1).max(500),
10
- amountMode: z.enum(['fixed', 'free']),
11
- expiresAt: z.iso.datetime().nullable(),
12
+ amount_mode: z.enum(['fixed', 'free']),
13
+ expires_at: unixSecondsSchema.nullable(),
12
14
  })
13
15
  .strict();
14
16
  export const createContributionSchema = z
15
17
  .object({
16
18
  purpose: contributionDetailsSchema.shape.purpose,
17
- amountMode: contributionDetailsSchema.shape.amountMode,
19
+ amount_mode: contributionDetailsSchema.shape.amount_mode,
18
20
  amount: contributionAmountSchema.optional(),
19
21
  currency: z.literal('FAIR'),
20
- expiresAt: z.iso.datetime().nullable().optional(),
22
+ expires_at: unixSecondsSchema.nullable().optional(),
21
23
  })
22
24
  .strict()
23
- .refine((v) => (v.amountMode === 'free' ? v.amount === undefined : v.amount !== undefined), 'Fixed contributions require an amount; free contributions omit it');
25
+ .refine((v) => (v.amount_mode === 'free' ? v.amount === undefined : v.amount !== undefined), 'Fixed contributions require an amount; free contributions omit it');
24
26
  export const contributionLinkSchema = z
25
27
  .object({
26
28
  id: z.string(),
29
+ object: z.literal('payment_link'),
27
30
  amount: z.string(),
28
31
  currency: z.literal('FAIR'),
29
32
  network: z.enum(['mainnet', 'testnet']),
30
33
  active: z.boolean(),
31
34
  url: z.url(),
32
35
  contribution: contributionDetailsSchema,
33
- createdAt: z.iso.datetime(),
36
+ created: unixSecondsSchema,
34
37
  })
35
38
  .strict();
36
- export const contributionListSchema = z
37
- .object({ items: z.array(contributionLinkSchema), nextCursor: z.string().nullable() })
38
- .strict();
39
+ /**
40
+ * The one list envelope (ADR 0014 D1): `url` is the path that was listed.
41
+ */
42
+ function listSchema(item) {
43
+ return z
44
+ .object({
45
+ object: z.literal('list'),
46
+ data: z.array(item),
47
+ has_more: z.boolean(),
48
+ url: z.string(),
49
+ })
50
+ .strict();
51
+ }
52
+ export const contributionListSchema = listSchema(contributionLinkSchema);
39
53
  export const contributionCollectionSchema = z
40
54
  .object({
41
55
  id: z.string(),
56
+ object: z.literal('payment_intent'),
42
57
  amount: z.string(),
43
58
  currency: z.literal('FAIR'),
44
59
  status: z.string(),
45
- createdAt: z.iso.datetime(),
46
- refundCapability: z.literal('unsupported_non_custodial'),
60
+ created: unixSecondsSchema,
61
+ refund_capability: z.literal('unsupported_non_custodial'),
47
62
  refunds: z.array(z
48
63
  .object({
49
64
  id: z.string(),
65
+ object: z.literal('refund'),
50
66
  amount: z.string(),
51
67
  status: z.string(),
52
- createdAt: z.iso.datetime(),
68
+ created: unixSecondsSchema,
53
69
  })
54
70
  .strict()),
55
71
  })
56
72
  .strict();
57
- export const contributionCollectionListSchema = z
58
- .object({ items: z.array(contributionCollectionSchema), nextCursor: z.string().nullable() })
59
- .strict();
73
+ export const contributionCollectionListSchema = listSchema(contributionCollectionSchema);
74
+ const unixSecondsQuery = z.coerce.number().int().nonnegative();
75
+ /**
76
+ * The list parameters every list accepts (ADR 0014 D1), newest first:
77
+ *
78
+ * - `limit` 1–100, default 10;
79
+ * - `starting_after` — the id of the last object of the previous page — or
80
+ * `ending_before` — the id of the first object of the current one, which
81
+ * pages backwards and still answers newest first. Never both;
82
+ * - `created` (one second) or `created[gt|gte|lt|lte]`, Unix seconds.
83
+ *
84
+ * Cursors are resolved by the gateway inside the caller's scope; one naming
85
+ * anything else is a 400 with `param` naming the cursor.
86
+ */
87
+ export const listQueryShape = {
88
+ limit: z.coerce.number().int().min(1).max(100).default(10),
89
+ starting_after: z.string().min(1).max(255).optional(),
90
+ ending_before: z.string().min(1).max(255).optional(),
91
+ created: z
92
+ .union([
93
+ unixSecondsQuery.transform((x) => ({ gte: x, lte: x })),
94
+ z
95
+ .object({
96
+ gt: unixSecondsQuery.optional(),
97
+ gte: unixSecondsQuery.optional(),
98
+ lt: unixSecondsQuery.optional(),
99
+ lte: unixSecondsQuery.optional(),
100
+ })
101
+ .strict(),
102
+ ])
103
+ .optional(),
104
+ };
105
+ /**
106
+ * Paging a contribution list: the list parameters (`link_…` cursors for links,
107
+ * `pi_…` for collections) plus the environment the Test/Live toggle selects.
108
+ */
60
109
  export const contributionPageQuerySchema = z
61
110
  .object({
62
- limit: z.coerce.number().int().min(1).max(100).default(20),
63
- cursor: z.string().max(1000).optional(),
111
+ ...listQueryShape,
64
112
  environment: z.enum(['development', 'staging', 'production']),
65
113
  })
66
- .strict();
114
+ .strict()
115
+ .refine((query) => query.starting_after === undefined || query.ending_before === undefined, {
116
+ message: 'starting_after and ending_before are mutually exclusive',
117
+ path: ['ending_before'],
118
+ });
67
119
  export const contributionMintSchema = z
68
120
  .object({ amount: contributionAmountSchema.optional() })
69
121
  .strict();
@@ -1,11 +1,18 @@
1
1
  import { z } from 'zod';
2
2
  import { createContributionSchema, contributionLinkSchema, contributionListSchema, contributionCollectionListSchema, contributionPatchSchema, } from './index.js';
3
+ const requestIdHeader = {
4
+ 'Request-Id': {
5
+ description: 'Identifies this request to Peable support.',
6
+ schema: { type: 'string' },
7
+ },
8
+ };
3
9
  const path = '/v1/organizations/{organizationId}/applications/{applicationId}/contributions';
4
10
  export const contributionRoutes = [
5
11
  {
6
12
  method: 'post',
7
13
  path,
8
14
  operationId: 'createContribution',
15
+ idempotencyKey: true,
9
16
  body: createContributionSchema,
10
17
  response: contributionLinkSchema,
11
18
  status: 201,
@@ -18,7 +25,7 @@ export const contributionRoutes = [
18
25
  status: 200,
19
26
  },
20
27
  {
21
- method: 'patch',
28
+ method: 'post',
22
29
  path: `${path}/{id}`,
23
30
  operationId: 'setContributionActive',
24
31
  body: contributionPatchSchema,
@@ -54,9 +61,40 @@ export function contributionOpenApi() {
54
61
  parameters.push({
55
62
  in: 'query',
56
63
  name: 'limit',
57
- schema: { type: 'integer', minimum: 1, maximum: 100, default: 20 },
58
- }, { in: 'query', name: 'cursor', schema: { type: 'string' } });
59
- if (route.method === 'post')
64
+ schema: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
65
+ }, {
66
+ in: 'query',
67
+ name: 'starting_after',
68
+ description: 'The id of the last object on the previous page.',
69
+ schema: { type: 'string' },
70
+ }, {
71
+ in: 'query',
72
+ name: 'ending_before',
73
+ description: 'The id of the first object on the current page; pages backwards, newest first.',
74
+ schema: { type: 'string' },
75
+ }, {
76
+ in: 'query',
77
+ name: 'created',
78
+ description: 'Unix seconds: one second, or `created[gt|gte|lt|lte]`.',
79
+ style: 'deepObject',
80
+ explode: true,
81
+ schema: {
82
+ oneOf: [
83
+ { type: 'integer', minimum: 0 },
84
+ {
85
+ type: 'object',
86
+ additionalProperties: false,
87
+ properties: {
88
+ gt: { type: 'integer', minimum: 0 },
89
+ gte: { type: 'integer', minimum: 0 },
90
+ lt: { type: 'integer', minimum: 0 },
91
+ lte: { type: 'integer', minimum: 0 },
92
+ },
93
+ },
94
+ ],
95
+ },
96
+ });
97
+ if ('idempotencyKey' in route)
60
98
  parameters.push({
61
99
  in: 'header',
62
100
  name: 'Idempotency-Key',
@@ -78,10 +116,12 @@ export function contributionOpenApi() {
78
116
  responses: {
79
117
  [route.status]: {
80
118
  description: 'Success',
119
+ headers: requestIdHeader,
81
120
  content: { 'application/json': { schema: z.toJSONSchema(route.response) } },
82
121
  },
83
122
  default: {
84
123
  description: 'Peable error envelope; HTTP status identifies failure',
124
+ headers: requestIdHeader,
85
125
  content: {
86
126
  'application/json': {
87
127
  schema: {
@@ -90,8 +130,14 @@ export function contributionOpenApi() {
90
130
  properties: {
91
131
  error: {
92
132
  type: 'object',
93
- required: ['type', 'message'],
94
- properties: { type: { type: 'string' }, message: { type: 'string' } },
133
+ required: ['type', 'message', 'request_id'],
134
+ properties: {
135
+ type: { type: 'string' },
136
+ code: { type: 'string' },
137
+ param: { type: 'string' },
138
+ message: { type: 'string' },
139
+ request_id: { type: ['string', 'null'] },
140
+ },
95
141
  },
96
142
  },
97
143
  },
@@ -105,7 +151,7 @@ export function contributionOpenApi() {
105
151
  openapi: '3.1.0',
106
152
  info: {
107
153
  title: 'Peable organization contributions',
108
- version: '0.1.0',
154
+ version: '0.2.0',
109
155
  description: 'One-off links. Human Oxy session for management; existing /v1/payment_links/{id}/public and /payment_intent remain anonymous. Fixed/free amounts use FAIR base units (8 decimals); the registered merchant determines the network. Refunds cannot be created by the watch-only gateway. No recurring billing.',
110
156
  },
111
157
  servers: [{ url: 'https://api.peable.to' }],
@@ -1,28 +1,29 @@
1
1
  import { z } from 'zod';
2
2
  export declare const contributionAmountSchema: z.ZodString;
3
3
  export declare const contributionDetailsSchema: z.ZodObject<{
4
- organizationId: z.ZodString;
4
+ organization_id: z.ZodString;
5
5
  purpose: z.ZodString;
6
- amountMode: z.ZodEnum<{
6
+ amount_mode: z.ZodEnum<{
7
7
  fixed: "fixed";
8
8
  free: "free";
9
9
  }>;
10
- expiresAt: z.ZodNullable<z.ZodISODateTime>;
10
+ expires_at: z.ZodNullable<z.ZodNumber>;
11
11
  }, z.core.$strict>;
12
12
  export type ContributionDetails = z.infer<typeof contributionDetailsSchema>;
13
13
  export declare const createContributionSchema: z.ZodObject<{
14
14
  purpose: z.ZodString;
15
- amountMode: z.ZodEnum<{
15
+ amount_mode: z.ZodEnum<{
16
16
  fixed: "fixed";
17
17
  free: "free";
18
18
  }>;
19
19
  amount: z.ZodOptional<z.ZodString>;
20
20
  currency: z.ZodLiteral<"FAIR">;
21
- expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
21
+ expires_at: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
22
22
  }, z.core.$strict>;
23
23
  export type CreateContribution = z.infer<typeof createContributionSchema>;
24
24
  export declare const contributionLinkSchema: z.ZodObject<{
25
25
  id: z.ZodString;
26
+ object: z.ZodLiteral<"payment_link">;
26
27
  amount: z.ZodString;
27
28
  currency: z.ZodLiteral<"FAIR">;
28
29
  network: z.ZodEnum<{
@@ -32,20 +33,22 @@ export declare const contributionLinkSchema: z.ZodObject<{
32
33
  active: z.ZodBoolean;
33
34
  url: z.ZodURL;
34
35
  contribution: z.ZodObject<{
35
- organizationId: z.ZodString;
36
+ organization_id: z.ZodString;
36
37
  purpose: z.ZodString;
37
- amountMode: z.ZodEnum<{
38
+ amount_mode: z.ZodEnum<{
38
39
  fixed: "fixed";
39
40
  free: "free";
40
41
  }>;
41
- expiresAt: z.ZodNullable<z.ZodISODateTime>;
42
+ expires_at: z.ZodNullable<z.ZodNumber>;
42
43
  }, z.core.$strict>;
43
- createdAt: z.ZodISODateTime;
44
+ created: z.ZodNumber;
44
45
  }, z.core.$strict>;
45
46
  export type ContributionLink = z.infer<typeof contributionLinkSchema>;
46
47
  export declare const contributionListSchema: z.ZodObject<{
47
- items: z.ZodArray<z.ZodObject<{
48
+ object: z.ZodLiteral<"list">;
49
+ data: z.ZodArray<z.ZodObject<{
48
50
  id: z.ZodString;
51
+ object: z.ZodLiteral<"payment_link">;
49
52
  amount: z.ZodString;
50
53
  currency: z.ZodLiteral<"FAIR">;
51
54
  network: z.ZodEnum<{
@@ -55,57 +58,106 @@ export declare const contributionListSchema: z.ZodObject<{
55
58
  active: z.ZodBoolean;
56
59
  url: z.ZodURL;
57
60
  contribution: z.ZodObject<{
58
- organizationId: z.ZodString;
61
+ organization_id: z.ZodString;
59
62
  purpose: z.ZodString;
60
- amountMode: z.ZodEnum<{
63
+ amount_mode: z.ZodEnum<{
61
64
  fixed: "fixed";
62
65
  free: "free";
63
66
  }>;
64
- expiresAt: z.ZodNullable<z.ZodISODateTime>;
67
+ expires_at: z.ZodNullable<z.ZodNumber>;
65
68
  }, z.core.$strict>;
66
- createdAt: z.ZodISODateTime;
69
+ created: z.ZodNumber;
67
70
  }, z.core.$strict>>;
68
- nextCursor: z.ZodNullable<z.ZodString>;
71
+ has_more: z.ZodBoolean;
72
+ url: z.ZodString;
69
73
  }, z.core.$strict>;
74
+ export type ContributionList = z.infer<typeof contributionListSchema>;
70
75
  export declare const contributionCollectionSchema: z.ZodObject<{
71
76
  id: z.ZodString;
77
+ object: z.ZodLiteral<"payment_intent">;
72
78
  amount: z.ZodString;
73
79
  currency: z.ZodLiteral<"FAIR">;
74
80
  status: z.ZodString;
75
- createdAt: z.ZodISODateTime;
76
- refundCapability: z.ZodLiteral<"unsupported_non_custodial">;
81
+ created: z.ZodNumber;
82
+ refund_capability: z.ZodLiteral<"unsupported_non_custodial">;
77
83
  refunds: z.ZodArray<z.ZodObject<{
78
84
  id: z.ZodString;
85
+ object: z.ZodLiteral<"refund">;
79
86
  amount: z.ZodString;
80
87
  status: z.ZodString;
81
- createdAt: z.ZodISODateTime;
88
+ created: z.ZodNumber;
82
89
  }, z.core.$strict>>;
83
90
  }, z.core.$strict>;
91
+ export type ContributionCollection = z.infer<typeof contributionCollectionSchema>;
84
92
  export declare const contributionCollectionListSchema: z.ZodObject<{
85
- items: z.ZodArray<z.ZodObject<{
93
+ object: z.ZodLiteral<"list">;
94
+ data: z.ZodArray<z.ZodObject<{
86
95
  id: z.ZodString;
96
+ object: z.ZodLiteral<"payment_intent">;
87
97
  amount: z.ZodString;
88
98
  currency: z.ZodLiteral<"FAIR">;
89
99
  status: z.ZodString;
90
- createdAt: z.ZodISODateTime;
91
- refundCapability: z.ZodLiteral<"unsupported_non_custodial">;
100
+ created: z.ZodNumber;
101
+ refund_capability: z.ZodLiteral<"unsupported_non_custodial">;
92
102
  refunds: z.ZodArray<z.ZodObject<{
93
103
  id: z.ZodString;
104
+ object: z.ZodLiteral<"refund">;
94
105
  amount: z.ZodString;
95
106
  status: z.ZodString;
96
- createdAt: z.ZodISODateTime;
107
+ created: z.ZodNumber;
97
108
  }, z.core.$strict>>;
98
109
  }, z.core.$strict>>;
99
- nextCursor: z.ZodNullable<z.ZodString>;
110
+ has_more: z.ZodBoolean;
111
+ url: z.ZodString;
100
112
  }, z.core.$strict>;
101
- export declare const contributionPageQuerySchema: z.ZodObject<{
113
+ /**
114
+ * The list parameters every list accepts (ADR 0014 D1), newest first:
115
+ *
116
+ * - `limit` 1–100, default 10;
117
+ * - `starting_after` — the id of the last object of the previous page — or
118
+ * `ending_before` — the id of the first object of the current one, which
119
+ * pages backwards and still answers newest first. Never both;
120
+ * - `created` (one second) or `created[gt|gte|lt|lte]`, Unix seconds.
121
+ *
122
+ * Cursors are resolved by the gateway inside the caller's scope; one naming
123
+ * anything else is a 400 with `param` naming the cursor.
124
+ */
125
+ export declare const listQueryShape: {
102
126
  limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
103
- cursor: z.ZodOptional<z.ZodString>;
127
+ starting_after: z.ZodOptional<z.ZodString>;
128
+ ending_before: z.ZodOptional<z.ZodString>;
129
+ created: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<{
130
+ gte: number;
131
+ lte: number;
132
+ }, number>>, z.ZodObject<{
133
+ gt: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
134
+ gte: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
135
+ lt: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
136
+ lte: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
137
+ }, z.core.$strict>]>>;
138
+ };
139
+ /**
140
+ * Paging a contribution list: the list parameters (`link_…` cursors for links,
141
+ * `pi_…` for collections) plus the environment the Test/Live toggle selects.
142
+ */
143
+ export declare const contributionPageQuerySchema: z.ZodObject<{
104
144
  environment: z.ZodEnum<{
105
145
  development: "development";
106
146
  staging: "staging";
107
147
  production: "production";
108
148
  }>;
149
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
150
+ starting_after: z.ZodOptional<z.ZodString>;
151
+ ending_before: z.ZodOptional<z.ZodString>;
152
+ created: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<{
153
+ gte: number;
154
+ lte: number;
155
+ }, number>>, z.ZodObject<{
156
+ gt: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
157
+ gte: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
158
+ lt: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
159
+ lte: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
160
+ }, z.core.$strict>]>>;
109
161
  }, z.core.$strict>;
110
162
  export declare const contributionMintSchema: z.ZodObject<{
111
163
  amount: z.ZodOptional<z.ZodString>;
@@ -3,18 +3,20 @@ export declare const contributionRoutes: readonly [{
3
3
  readonly method: "post";
4
4
  readonly path: "/v1/organizations/{organizationId}/applications/{applicationId}/contributions";
5
5
  readonly operationId: "createContribution";
6
+ readonly idempotencyKey: true;
6
7
  readonly body: z.ZodObject<{
7
8
  purpose: z.ZodString;
8
- amountMode: z.ZodEnum<{
9
+ amount_mode: z.ZodEnum<{
9
10
  fixed: "fixed";
10
11
  free: "free";
11
12
  }>;
12
13
  amount: z.ZodOptional<z.ZodString>;
13
14
  currency: z.ZodLiteral<"FAIR">;
14
- expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
15
+ expires_at: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
15
16
  }, z.core.$strict>;
16
17
  readonly response: z.ZodObject<{
17
18
  id: z.ZodString;
19
+ object: z.ZodLiteral<"payment_link">;
18
20
  amount: z.ZodString;
19
21
  currency: z.ZodLiteral<"FAIR">;
20
22
  network: z.ZodEnum<{
@@ -24,15 +26,15 @@ export declare const contributionRoutes: readonly [{
24
26
  active: z.ZodBoolean;
25
27
  url: z.ZodURL;
26
28
  contribution: z.ZodObject<{
27
- organizationId: z.ZodString;
29
+ organization_id: z.ZodString;
28
30
  purpose: z.ZodString;
29
- amountMode: z.ZodEnum<{
31
+ amount_mode: z.ZodEnum<{
30
32
  fixed: "fixed";
31
33
  free: "free";
32
34
  }>;
33
- expiresAt: z.ZodNullable<z.ZodISODateTime>;
35
+ expires_at: z.ZodNullable<z.ZodNumber>;
34
36
  }, z.core.$strict>;
35
- createdAt: z.ZodISODateTime;
37
+ created: z.ZodNumber;
36
38
  }, z.core.$strict>;
37
39
  readonly status: 201;
38
40
  }, {
@@ -40,8 +42,10 @@ export declare const contributionRoutes: readonly [{
40
42
  readonly path: "/v1/organizations/{organizationId}/applications/{applicationId}/contributions";
41
43
  readonly operationId: "listContributions";
42
44
  readonly response: z.ZodObject<{
43
- items: z.ZodArray<z.ZodObject<{
45
+ object: z.ZodLiteral<"list">;
46
+ data: z.ZodArray<z.ZodObject<{
44
47
  id: z.ZodString;
48
+ object: z.ZodLiteral<"payment_link">;
45
49
  amount: z.ZodString;
46
50
  currency: z.ZodLiteral<"FAIR">;
47
51
  network: z.ZodEnum<{
@@ -51,21 +55,22 @@ export declare const contributionRoutes: readonly [{
51
55
  active: z.ZodBoolean;
52
56
  url: z.ZodURL;
53
57
  contribution: z.ZodObject<{
54
- organizationId: z.ZodString;
58
+ organization_id: z.ZodString;
55
59
  purpose: z.ZodString;
56
- amountMode: z.ZodEnum<{
60
+ amount_mode: z.ZodEnum<{
57
61
  fixed: "fixed";
58
62
  free: "free";
59
63
  }>;
60
- expiresAt: z.ZodNullable<z.ZodISODateTime>;
64
+ expires_at: z.ZodNullable<z.ZodNumber>;
61
65
  }, z.core.$strict>;
62
- createdAt: z.ZodISODateTime;
66
+ created: z.ZodNumber;
63
67
  }, z.core.$strict>>;
64
- nextCursor: z.ZodNullable<z.ZodString>;
68
+ has_more: z.ZodBoolean;
69
+ url: z.ZodString;
65
70
  }, z.core.$strict>;
66
71
  readonly status: 200;
67
72
  }, {
68
- readonly method: "patch";
73
+ readonly method: "post";
69
74
  readonly path: "/v1/organizations/{organizationId}/applications/{applicationId}/contributions/{id}";
70
75
  readonly operationId: "setContributionActive";
71
76
  readonly body: z.ZodObject<{
@@ -73,6 +78,7 @@ export declare const contributionRoutes: readonly [{
73
78
  }, z.core.$strict>;
74
79
  readonly response: z.ZodObject<{
75
80
  id: z.ZodString;
81
+ object: z.ZodLiteral<"payment_link">;
76
82
  amount: z.ZodString;
77
83
  currency: z.ZodLiteral<"FAIR">;
78
84
  network: z.ZodEnum<{
@@ -82,15 +88,15 @@ export declare const contributionRoutes: readonly [{
82
88
  active: z.ZodBoolean;
83
89
  url: z.ZodURL;
84
90
  contribution: z.ZodObject<{
85
- organizationId: z.ZodString;
91
+ organization_id: z.ZodString;
86
92
  purpose: z.ZodString;
87
- amountMode: z.ZodEnum<{
93
+ amount_mode: z.ZodEnum<{
88
94
  fixed: "fixed";
89
95
  free: "free";
90
96
  }>;
91
- expiresAt: z.ZodNullable<z.ZodISODateTime>;
97
+ expires_at: z.ZodNullable<z.ZodNumber>;
92
98
  }, z.core.$strict>;
93
- createdAt: z.ZodISODateTime;
99
+ created: z.ZodNumber;
94
100
  }, z.core.$strict>;
95
101
  readonly status: 200;
96
102
  }, {
@@ -98,21 +104,25 @@ export declare const contributionRoutes: readonly [{
98
104
  readonly path: "/v1/organizations/{organizationId}/applications/{applicationId}/contributions/{id}/collections";
99
105
  readonly operationId: "listContributionCollections";
100
106
  readonly response: z.ZodObject<{
101
- items: z.ZodArray<z.ZodObject<{
107
+ object: z.ZodLiteral<"list">;
108
+ data: z.ZodArray<z.ZodObject<{
102
109
  id: z.ZodString;
110
+ object: z.ZodLiteral<"payment_intent">;
103
111
  amount: z.ZodString;
104
112
  currency: z.ZodLiteral<"FAIR">;
105
113
  status: z.ZodString;
106
- createdAt: z.ZodISODateTime;
107
- refundCapability: z.ZodLiteral<"unsupported_non_custodial">;
114
+ created: z.ZodNumber;
115
+ refund_capability: z.ZodLiteral<"unsupported_non_custodial">;
108
116
  refunds: z.ZodArray<z.ZodObject<{
109
117
  id: z.ZodString;
118
+ object: z.ZodLiteral<"refund">;
110
119
  amount: z.ZodString;
111
120
  status: z.ZodString;
112
- createdAt: z.ZodISODateTime;
121
+ created: z.ZodNumber;
113
122
  }, z.core.$strict>>;
114
123
  }, z.core.$strict>>;
115
- nextCursor: z.ZodNullable<z.ZodString>;
124
+ has_more: z.ZodBoolean;
125
+ url: z.ZodString;
116
126
  }, z.core.$strict>;
117
127
  readonly status: 200;
118
128
  }];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peable.to/contracts",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
4
  "description": "Validated Peable contribution-link contracts",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",