@devvit/shared-types 0.11.0-next-2024-08-15-37b3f7371.0 → 0.11.0-next-2024-08-20-4ebb1a01f.0
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +6 -6
- package/payments/Order.d.ts +2 -2
- package/payments/Order.d.ts.map +1 -1
- package/payments/Order.js +6 -5
- package/payments/Product.d.ts +20 -0
- package/payments/Product.d.ts.map +1 -1
- package/payments/Product.js +36 -0
- package/payments/index.d.ts.map +1 -1
- package/payments/index.js +1 -1
- package/payments/products.schema.json +7 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@devvit/shared-types",
|
3
|
-
"version": "0.11.0-next-2024-08-
|
3
|
+
"version": "0.11.0-next-2024-08-20-4ebb1a01f.0",
|
4
4
|
"license": "BSD-3-Clause",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -24,14 +24,14 @@
|
|
24
24
|
},
|
25
25
|
"types": "./index.d.ts",
|
26
26
|
"dependencies": {
|
27
|
-
"@devvit/protos": "0.11.0-next-2024-08-
|
27
|
+
"@devvit/protos": "0.11.0-next-2024-08-20-4ebb1a01f.0",
|
28
28
|
"jsonschema": "1.4.1",
|
29
29
|
"uuid": "9.0.0"
|
30
30
|
},
|
31
31
|
"devDependencies": {
|
32
|
-
"@devvit/eslint-config": "0.11.0-next-2024-08-
|
33
|
-
"@devvit/repo-tools": "0.11.0-next-2024-08-
|
34
|
-
"@devvit/tsconfig": "0.11.0-next-2024-08-
|
32
|
+
"@devvit/eslint-config": "0.11.0-next-2024-08-20-4ebb1a01f.0",
|
33
|
+
"@devvit/repo-tools": "0.11.0-next-2024-08-20-4ebb1a01f.0",
|
34
|
+
"@devvit/tsconfig": "0.11.0-next-2024-08-20-4ebb1a01f.0",
|
35
35
|
"@types/redis-mock": "0.17.1",
|
36
36
|
"@types/uuid": "9.0.0",
|
37
37
|
"eslint": "8.9.0",
|
@@ -45,5 +45,5 @@
|
|
45
45
|
"directory": "dist"
|
46
46
|
},
|
47
47
|
"source": "./src/index.ts",
|
48
|
-
"gitHead": "
|
48
|
+
"gitHead": "5fc4461855bfebaafcbfefd06e09d8fb93dd2bb3"
|
49
49
|
}
|
package/payments/Order.d.ts
CHANGED
@@ -5,13 +5,13 @@ import type { Product } from './Product.js';
|
|
5
5
|
* The status of an order.
|
6
6
|
*/
|
7
7
|
export declare const enum OrderStatus {
|
8
|
-
UNDEFINED = "UNDEFINED",
|
9
8
|
NEW = "NEW",
|
10
9
|
CREATED = "CREATED",
|
11
10
|
PAID = "PAID",
|
12
11
|
DELIVERED = "DELIVERED",
|
13
12
|
CANCELED = "CANCELED",
|
14
|
-
REVERTED = "REVERTED"
|
13
|
+
REVERTED = "REVERTED",
|
14
|
+
UNRECOGNIZED = "UNRECOGNIZED"
|
15
15
|
}
|
16
16
|
/**
|
17
17
|
* Maps an OrderStatus enum to the corresponding protobuf enum value.
|
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,
|
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,GAAG,QAAQ;IACX,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,YAAY,iBAAiB;CAC9B;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,WAAW,GAAG,gBAAgB,CAiB3E;AAyBD;;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,IAAI,CAAC;IACvB,sCAAsC;IACtC,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,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
@@ -5,13 +5,13 @@ import { productFromProto } from './Product.js';
|
|
5
5
|
*/
|
6
6
|
export var OrderStatus;
|
7
7
|
(function (OrderStatus) {
|
8
|
-
OrderStatus["UNDEFINED"] = "UNDEFINED";
|
9
8
|
OrderStatus["NEW"] = "NEW";
|
10
9
|
OrderStatus["CREATED"] = "CREATED";
|
11
10
|
OrderStatus["PAID"] = "PAID";
|
12
11
|
OrderStatus["DELIVERED"] = "DELIVERED";
|
13
12
|
OrderStatus["CANCELED"] = "CANCELED";
|
14
13
|
OrderStatus["REVERTED"] = "REVERTED";
|
14
|
+
OrderStatus["UNRECOGNIZED"] = "UNRECOGNIZED";
|
15
15
|
})(OrderStatus || (OrderStatus = {}));
|
16
16
|
/**
|
17
17
|
* Maps an OrderStatus enum to the corresponding protobuf enum value.
|
@@ -30,8 +30,8 @@ export function mapOrderStatusToProto(status) {
|
|
30
30
|
return OrderStatusProto.ORDER_STATUS_CANCELED;
|
31
31
|
case OrderStatus.REVERTED:
|
32
32
|
return OrderStatusProto.ORDER_STATUS_REVERTED;
|
33
|
-
|
34
|
-
|
33
|
+
case OrderStatus.UNRECOGNIZED:
|
34
|
+
return OrderStatusProto.UNRECOGNIZED;
|
35
35
|
}
|
36
36
|
}
|
37
37
|
/**
|
@@ -51,8 +51,9 @@ function mapProtoToOrderStatus(status) {
|
|
51
51
|
return OrderStatus.CANCELED;
|
52
52
|
case OrderStatusProto.ORDER_STATUS_REVERTED:
|
53
53
|
return OrderStatus.REVERTED;
|
54
|
-
|
55
|
-
|
54
|
+
case OrderStatusProto.ORDER_STATUS_UNSPECIFIED:
|
55
|
+
case OrderStatusProto.UNRECOGNIZED:
|
56
|
+
return OrderStatus.UNRECOGNIZED;
|
56
57
|
}
|
57
58
|
}
|
58
59
|
/**
|
package/payments/Product.d.ts
CHANGED
@@ -1,8 +1,27 @@
|
|
1
1
|
import type { Product as ProductProto } from '@devvit/protos/payments.js';
|
2
|
+
import { AccountingType as AccountingTypeProto } from '@devvit/protos/payments.js';
|
2
3
|
/**
|
3
4
|
* A unique identifier for a product.
|
4
5
|
*/
|
5
6
|
export type SKU = string;
|
7
|
+
export declare enum AccountingType {
|
8
|
+
INSTANT = "INSTANT",
|
9
|
+
DURABLE = "DURABLE",
|
10
|
+
CONSUMABLE = "CONSUMABLE",
|
11
|
+
VALID_FOR_1D = "VALID_FOR_1D",
|
12
|
+
VALID_FOR_7D = "VALID_FOR_7D",
|
13
|
+
VALID_FOR_30D = "VALID_FOR_30D",
|
14
|
+
VALID_FOR_1Y = "VALID_FOR_1Y",
|
15
|
+
UNRECOGNIZED = "UNRECOGNIZED"
|
16
|
+
}
|
17
|
+
/**
|
18
|
+
* Maps an AccountingType enum to the corresponding protobuf enum value.
|
19
|
+
*/
|
20
|
+
export declare function mapAccountingTypeToProto(type: AccountingType): AccountingTypeProto;
|
21
|
+
/**
|
22
|
+
* Maps an AccountingType protobuf enum value to the corresponding AccountingType enum.
|
23
|
+
*/
|
24
|
+
export declare function mapProtoToAccountingType(typeProto: AccountingTypeProto): AccountingType;
|
6
25
|
/**
|
7
26
|
* A product that can be sold by Devvit developers
|
8
27
|
* and purchased by Reddit users.
|
@@ -11,6 +30,7 @@ export type Product = {
|
|
11
30
|
sku: SKU;
|
12
31
|
price: number;
|
13
32
|
displayName: string;
|
33
|
+
accountingType: AccountingType;
|
14
34
|
description?: string;
|
15
35
|
metadata: Readonly<Record<string, string>>;
|
16
36
|
images?: {
|
@@ -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,4BAA4B,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,4BAA4B,CAAC;AAC1E,OAAO,EAAE,cAAc,IAAI,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAInF;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC;AAEzB,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAC7B,YAAY,iBAAiB;IAC7B,aAAa,kBAAkB;IAC/B,YAAY,iBAAiB;IAC7B,YAAY,iBAAiB;CAC9B;AAaD;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,cAAc,GAAG,mBAAmB,CAElF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,mBAAmB,GAAG,cAAc,CAGvF;AAED;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,GAAG,EAAE,GAAG,CAAC;IACT,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,cAAc,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,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,CAW5D;AAED,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAI7E"}
|
package/payments/Product.js
CHANGED
@@ -1,5 +1,40 @@
|
|
1
|
+
import { AccountingType as AccountingTypeProto } from '@devvit/protos/payments.js';
|
1
2
|
import { assertNonNull } from '../NonNull.js';
|
2
3
|
import { v5 as uuidv5 } from 'uuid';
|
4
|
+
export var AccountingType;
|
5
|
+
(function (AccountingType) {
|
6
|
+
AccountingType["INSTANT"] = "INSTANT";
|
7
|
+
AccountingType["DURABLE"] = "DURABLE";
|
8
|
+
AccountingType["CONSUMABLE"] = "CONSUMABLE";
|
9
|
+
AccountingType["VALID_FOR_1D"] = "VALID_FOR_1D";
|
10
|
+
AccountingType["VALID_FOR_7D"] = "VALID_FOR_7D";
|
11
|
+
AccountingType["VALID_FOR_30D"] = "VALID_FOR_30D";
|
12
|
+
AccountingType["VALID_FOR_1Y"] = "VALID_FOR_1Y";
|
13
|
+
AccountingType["UNRECOGNIZED"] = "UNRECOGNIZED";
|
14
|
+
})(AccountingType || (AccountingType = {}));
|
15
|
+
const accountTypeToProtoMapping = {
|
16
|
+
[AccountingType.INSTANT]: AccountingTypeProto.ACCOUNTING_TYPE_INSTANT,
|
17
|
+
[AccountingType.DURABLE]: AccountingTypeProto.ACCOUNTING_TYPE_DURABLE,
|
18
|
+
[AccountingType.CONSUMABLE]: AccountingTypeProto.ACCOUNTING_TYPE_CONSUMABLE,
|
19
|
+
[AccountingType.VALID_FOR_1D]: AccountingTypeProto.ACCOUNTING_TYPE_VALID_FOR_1D,
|
20
|
+
[AccountingType.VALID_FOR_7D]: AccountingTypeProto.ACCOUNTING_TYPE_VALID_FOR_7D,
|
21
|
+
[AccountingType.VALID_FOR_30D]: AccountingTypeProto.ACCOUNTING_TYPE_VALID_FOR_30D,
|
22
|
+
[AccountingType.VALID_FOR_1Y]: AccountingTypeProto.ACCOUNTING_TYPE_VALID_FOR_1Y,
|
23
|
+
[AccountingType.UNRECOGNIZED]: AccountingTypeProto.UNRECOGNIZED,
|
24
|
+
};
|
25
|
+
/**
|
26
|
+
* Maps an AccountingType enum to the corresponding protobuf enum value.
|
27
|
+
*/
|
28
|
+
export function mapAccountingTypeToProto(type) {
|
29
|
+
return accountTypeToProtoMapping[type] ?? AccountingTypeProto.UNRECOGNIZED;
|
30
|
+
}
|
31
|
+
/**
|
32
|
+
* Maps an AccountingType protobuf enum value to the corresponding AccountingType enum.
|
33
|
+
*/
|
34
|
+
export function mapProtoToAccountingType(typeProto) {
|
35
|
+
const entry = Object.entries(accountTypeToProtoMapping).find(([_, value]) => value === typeProto);
|
36
|
+
return entry ? entry[0] : AccountingType.UNRECOGNIZED;
|
37
|
+
}
|
3
38
|
/**
|
4
39
|
* Converts an Product protobuf message to an Product object.
|
5
40
|
*/
|
@@ -9,6 +44,7 @@ export function productFromProto(data) {
|
|
9
44
|
return {
|
10
45
|
sku: data.sku,
|
11
46
|
price: data.price.amount, // In Reddit Gold
|
47
|
+
accountingType: mapProtoToAccountingType(data.accountingType),
|
12
48
|
displayName: data.name,
|
13
49
|
description: data.description,
|
14
50
|
metadata: data.productMetadata,
|
package/payments/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/payments/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,wBAAwB,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/payments/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAuB"}
|
package/payments/index.js
CHANGED
@@ -33,6 +33,11 @@
|
|
33
33
|
"type": "integer",
|
34
34
|
"enum": [5, 25, 50, 100, 150, 250, 500, 1000, 2500]
|
35
35
|
},
|
36
|
+
"accountingType": {
|
37
|
+
"description": "The accounting type of the product",
|
38
|
+
"type": "string",
|
39
|
+
"enum": ["INSTANT", "DURABLE", "CONSUMABLE", "VALID_FOR_1D", "VALID_FOR_7D", "VALID_FOR_30D", "VALID_FOR_1Y"]
|
40
|
+
},
|
36
41
|
"images": {
|
37
42
|
"description": "The images associated with this product",
|
38
43
|
"type": "object",
|
@@ -64,7 +69,8 @@
|
|
64
69
|
"required": [
|
65
70
|
"sku",
|
66
71
|
"displayName",
|
67
|
-
"price"
|
72
|
+
"price",
|
73
|
+
"accountingType"
|
68
74
|
]
|
69
75
|
}
|
70
76
|
}
|