@devvit/shared-types 0.11.0-next-2024-07-11-178fc80d6.0 → 0.11.0-next-2024-07-11-c0e47b869.0
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +8 -7
- package/payments/Order.d.ts +1 -1
- package/payments/Order.d.ts.map +1 -1
- package/payments/Order.js +2 -2
- package/payments/Product.d.ts +4 -1
- package/payments/Product.d.ts.map +1 -1
- package/payments/Product.js +1 -1
- package/payments/index.d.ts +3 -0
- package/payments/index.d.ts.map +1 -0
- package/payments/index.js +2 -0
- package/payments/products.schema.json +72 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@devvit/shared-types",
|
3
|
-
"version": "0.11.0-next-2024-07-11-
|
3
|
+
"version": "0.11.0-next-2024-07-11-c0e47b869.0",
|
4
4
|
"license": "BSD-3-Clause",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -9,12 +9,13 @@
|
|
9
9
|
"type": "module",
|
10
10
|
"main": "./index.js",
|
11
11
|
"scripts": {
|
12
|
-
"build": "tsc",
|
12
|
+
"build": "tsc && yarn postbuild:copy-payments-schema",
|
13
13
|
"clean": "rm -rf .turbo coverage dist",
|
14
14
|
"clobber": "yarn clean && rm -rf node_modules",
|
15
15
|
"dev": "tsc -w",
|
16
16
|
"lint": "redlint .",
|
17
17
|
"lint:fix": "yarn lint --fix",
|
18
|
+
"postbuild:copy-payments-schema": "cp -a -f ./src/payments/products.schema.json ./dist/payments",
|
18
19
|
"prepublishOnly": "publish-package-json",
|
19
20
|
"test": "yarn test:unit && yarn test:types",
|
20
21
|
"test:types": "tsc --noEmit",
|
@@ -23,12 +24,12 @@
|
|
23
24
|
},
|
24
25
|
"types": "./index.d.ts",
|
25
26
|
"dependencies": {
|
26
|
-
"@devvit/protos": "0.11.0-next-2024-07-11-
|
27
|
+
"@devvit/protos": "0.11.0-next-2024-07-11-c0e47b869.0"
|
27
28
|
},
|
28
29
|
"devDependencies": {
|
29
|
-
"@devvit/eslint-config": "0.11.0-next-2024-07-11-
|
30
|
-
"@devvit/repo-tools": "0.11.0-next-2024-07-11-
|
31
|
-
"@devvit/tsconfig": "0.11.0-next-2024-07-11-
|
30
|
+
"@devvit/eslint-config": "0.11.0-next-2024-07-11-c0e47b869.0",
|
31
|
+
"@devvit/repo-tools": "0.11.0-next-2024-07-11-c0e47b869.0",
|
32
|
+
"@devvit/tsconfig": "0.11.0-next-2024-07-11-c0e47b869.0",
|
32
33
|
"@types/redis-mock": "0.17.1",
|
33
34
|
"eslint": "8.9.0",
|
34
35
|
"lit": "2.2.8",
|
@@ -41,5 +42,5 @@
|
|
41
42
|
"directory": "dist"
|
42
43
|
},
|
43
44
|
"source": "./src/index.ts",
|
44
|
-
"gitHead": "
|
45
|
+
"gitHead": "d34969059bb70bf842f44eaf808ba6452c208fa0"
|
45
46
|
}
|
package/payments/Order.d.ts
CHANGED
package/payments/Order.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Order.d.ts","sourceRoot":"","sources":["../../src/payments/Order.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C;;GAEG;AACH,0BAAkB,WAAW;IAC3B,SAAS,cAAc;IACvB,GAAG,QAAQ;IACX,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,QAAQ,aAAa;CACtB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,WAAW,GAAG,gBAAgB,CAiB3E;AAwBD;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,qCAAqC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,0CAA0C;IAC1C,MAAM,EAAE,WAAW,CAAC;IACpB,iCAAiC;IACjC,SAAS,EAAE,IAAI,GAAG,SAAS,CAAC;IAC5B,sCAAsC;IACtC,SAAS,EAAE,IAAI,GAAG,SAAS,CAAC;IAC5B,qCAAqC;IACrC,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,wBAAgB,
|
1
|
+
{"version":3,"file":"Order.d.ts","sourceRoot":"","sources":["../../src/payments/Order.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C;;GAEG;AACH,0BAAkB,WAAW;IAC3B,SAAS,cAAc;IACvB,GAAG,QAAQ;IACX,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,QAAQ,aAAa;CACtB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,WAAW,GAAG,gBAAgB,CAiB3E;AAwBD;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,qCAAqC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,0CAA0C;IAC1C,MAAM,EAAE,WAAW,CAAC;IACpB,iCAAiC;IACjC,SAAS,EAAE,IAAI,GAAG,SAAS,CAAC;IAC5B,sCAAsC;IACtC,SAAS,EAAE,IAAI,GAAG,SAAS,CAAC;IAC5B,qCAAqC;IACrC,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,KAAK,CAQtD"}
|
package/payments/Order.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { OrderStatus as OrderStatusProto } from '@devvit/protos/payments.js';
|
2
|
-
import {
|
2
|
+
import { productFromProto } from './Product.js';
|
3
3
|
/**
|
4
4
|
* The status of an order.
|
5
5
|
*/
|
@@ -58,7 +58,7 @@ function mapProtoToOrderStatus(status) {
|
|
58
58
|
/**
|
59
59
|
* Converts an Order protobuf message to an Order object.
|
60
60
|
*/
|
61
|
-
export function
|
61
|
+
export function orderFromProto(data) {
|
62
62
|
return {
|
63
63
|
id: data.id,
|
64
64
|
status: mapProtoToOrderStatus(data.status),
|
package/payments/Product.d.ts
CHANGED
@@ -11,9 +11,12 @@ export type Product = {
|
|
11
11
|
sku: SKU;
|
12
12
|
price: number;
|
13
13
|
metadata: Readonly<Record<string, string>>;
|
14
|
+
images?: {
|
15
|
+
icon: string;
|
16
|
+
};
|
14
17
|
};
|
15
18
|
/**
|
16
19
|
* Converts an Product protobuf message to an Product object.
|
17
20
|
*/
|
18
|
-
export declare function
|
21
|
+
export declare function productFromProto(data: ProductProto): Product;
|
19
22
|
//# sourceMappingURL=Product.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Product.d.ts","sourceRoot":"","sources":["../../src/payments/Product.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,yDAAyD,CAAC;AAGvG;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC;AAEzB;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,GAAG,EAAE,GAAG,CAAC;IACT,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;
|
1
|
+
{"version":3,"file":"Product.d.ts","sourceRoot":"","sources":["../../src/payments/Product.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,yDAAyD,CAAC;AAGvG;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC;AAEzB;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,GAAG,EAAE,GAAG,CAAC;IACT,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAQ5D"}
|
package/payments/Product.js
CHANGED
@@ -2,7 +2,7 @@ import { assertNonNull } from '../NonNull.js';
|
|
2
2
|
/**
|
3
3
|
* Converts an Product protobuf message to an Product object.
|
4
4
|
*/
|
5
|
-
export function
|
5
|
+
export function productFromProto(data) {
|
6
6
|
// Validate the incoming data
|
7
7
|
assertNonNull(data.price, 'Product price is null or undefined');
|
8
8
|
return {
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/payments/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
3
|
+
"id": "https://developers.reddit.com/payments/products.schema.json",
|
4
|
+
"title": "Devvit Payments - Product Schema",
|
5
|
+
"description": "Schema for Devvit products",
|
6
|
+
"type": "object",
|
7
|
+
"properties": {
|
8
|
+
"products": {
|
9
|
+
"type": "array",
|
10
|
+
"items": {
|
11
|
+
"type": "object",
|
12
|
+
"properties": {
|
13
|
+
"sku": {
|
14
|
+
"description": "The product sku used as a unique identifier",
|
15
|
+
"maxLength": 50,
|
16
|
+
"type": "string",
|
17
|
+
"pattern": "^[A-z0-9-_]+$"
|
18
|
+
},
|
19
|
+
"displayName": {
|
20
|
+
"description": "The product display name",
|
21
|
+
"maxLength": 50,
|
22
|
+
"type": "string",
|
23
|
+
"pattern": "^(?!\\s)[a-zA-Z0-9\\s]+(?<!\\s)$"
|
24
|
+
},
|
25
|
+
"description": {
|
26
|
+
"description": "The product description",
|
27
|
+
"type": "string",
|
28
|
+
"maxLength": 250
|
29
|
+
},
|
30
|
+
"price": {
|
31
|
+
"description": "The price of the product (unit: Reddit Gold)",
|
32
|
+
"type": "integer",
|
33
|
+
"minimum": 0
|
34
|
+
},
|
35
|
+
"images": {
|
36
|
+
"description": "The images associated with this product",
|
37
|
+
"type": "object",
|
38
|
+
"properties": {
|
39
|
+
"icon": {
|
40
|
+
"description": "The icon image URL (should be a path relative to /assets)",
|
41
|
+
"type": "string"
|
42
|
+
}
|
43
|
+
},
|
44
|
+
"patternProperties": {
|
45
|
+
"^.*$": {
|
46
|
+
"type": "string"
|
47
|
+
}
|
48
|
+
},
|
49
|
+
"additionalProperties": false,
|
50
|
+
"required": [
|
51
|
+
"icon"
|
52
|
+
]
|
53
|
+
},
|
54
|
+
"metadata": {
|
55
|
+
"description": "Additional metadata associated with this product",
|
56
|
+
"type": "object",
|
57
|
+
"patternProperties": {
|
58
|
+
"^.*$": {
|
59
|
+
"type": "string"
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
},
|
64
|
+
"required": [
|
65
|
+
"sku",
|
66
|
+
"displayName",
|
67
|
+
"price"
|
68
|
+
]
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|