opticedge-cloud-utils 1.0.45 → 1.1.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.
Files changed (82) hide show
  1. package/dist/db/mongo.js +1 -1
  2. package/dist/db/mongo2.js +1 -1
  3. package/dist/db/mongo3.js +1 -1
  4. package/dist/index.d.ts +7 -14
  5. package/dist/index.js +7 -14
  6. package/dist/{utils → tw}/tw-wallet.js +1 -1
  7. package/package.json +5 -4
  8. package/src/db/mongo.ts +1 -1
  9. package/src/db/mongo2.ts +1 -1
  10. package/src/db/mongo3.ts +1 -1
  11. package/src/index.ts +7 -14
  12. package/src/{utils → tw}/tw-wallet.ts +1 -1
  13. package/{src/auth/verify.test.ts → tests/auth.test.ts} +1 -1
  14. package/{src → tests}/db/mongo.test.ts +4 -4
  15. package/{src → tests}/db/mongo2.test.ts +5 -5
  16. package/{src → tests}/db/mongo3.test.ts +5 -5
  17. package/{src/utils → tests}/env.test.ts +1 -1
  18. package/{src/utils → tests}/regex.test.ts +1 -1
  19. package/{src/utils → tests}/secrets.test.ts +1 -1
  20. package/{src/utils → tests}/task.test.ts +1 -1
  21. package/{src/utils → tests/tw}/tw-utils.test.ts +1 -1
  22. package/{src/utils → tests/tw}/tw-wallet.test.ts +3 -4
  23. package/dist/auth/verify.test.d.ts +0 -1
  24. package/dist/auth/verify.test.js +0 -79
  25. package/dist/constants.d.ts +0 -2
  26. package/dist/constants.js +0 -7
  27. package/dist/db/mongo.test.d.ts +0 -1
  28. package/dist/db/mongo.test.js +0 -73
  29. package/dist/db/mongo2.test.d.ts +0 -1
  30. package/dist/db/mongo2.test.js +0 -86
  31. package/dist/db/mongo3.test.d.ts +0 -1
  32. package/dist/db/mongo3.test.js +0 -108
  33. package/dist/types/card.d.ts +0 -79
  34. package/dist/types/card.js +0 -19
  35. package/dist/types/notify.d.ts +0 -4
  36. package/dist/types/notify.js +0 -2
  37. package/dist/types/payment.d.ts +0 -1
  38. package/dist/types/payment.js +0 -2
  39. package/dist/types/pokemontcg.d.ts +0 -158
  40. package/dist/types/pokemontcg.js +0 -2
  41. package/dist/types/pricecharting.d.ts +0 -40
  42. package/dist/types/pricecharting.js +0 -2
  43. package/dist/types/user.d.ts +0 -37
  44. package/dist/types/user.js +0 -10
  45. package/dist/utils/env.test.d.ts +0 -1
  46. package/dist/utils/env.test.js +0 -17
  47. package/dist/utils/regex.test.d.ts +0 -1
  48. package/dist/utils/regex.test.js +0 -22
  49. package/dist/utils/secrets.test.d.ts +0 -1
  50. package/dist/utils/secrets.test.js +0 -38
  51. package/dist/utils/task.test.d.ts +0 -1
  52. package/dist/utils/task.test.js +0 -67
  53. package/dist/utils/tw-utils.test.d.ts +0 -1
  54. package/dist/utils/tw-utils.test.js +0 -26
  55. package/dist/utils/tw-wallet.test.d.ts +0 -1
  56. package/dist/utils/tw-wallet.test.js +0 -94
  57. package/src/constants.ts +0 -6
  58. package/src/types/card.ts +0 -82
  59. package/src/types/notify.ts +0 -4
  60. package/src/types/payment.ts +0 -1
  61. package/src/types/pokemontcg.ts +0 -162
  62. package/src/types/pricecharting.ts +0 -42
  63. package/src/types/user.ts +0 -38
  64. /package/dist/{auth/verify.d.ts → auth.d.ts} +0 -0
  65. /package/dist/{auth/verify.js → auth.js} +0 -0
  66. /package/dist/{utils/env.d.ts → env.d.ts} +0 -0
  67. /package/dist/{utils/env.js → env.js} +0 -0
  68. /package/dist/{utils/regex.d.ts → regex.d.ts} +0 -0
  69. /package/dist/{utils/regex.js → regex.js} +0 -0
  70. /package/dist/{utils/secrets.d.ts → secrets.d.ts} +0 -0
  71. /package/dist/{utils/secrets.js → secrets.js} +0 -0
  72. /package/dist/{utils/task.d.ts → task.d.ts} +0 -0
  73. /package/dist/{utils/task.js → task.js} +0 -0
  74. /package/dist/{utils → tw}/tw-utils.d.ts +0 -0
  75. /package/dist/{utils → tw}/tw-utils.js +0 -0
  76. /package/dist/{utils → tw}/tw-wallet.d.ts +0 -0
  77. /package/src/{auth/verify.ts → auth.ts} +0 -0
  78. /package/src/{utils/env.ts → env.ts} +0 -0
  79. /package/src/{utils/regex.ts → regex.ts} +0 -0
  80. /package/src/{utils/secrets.ts → secrets.ts} +0 -0
  81. /package/src/{utils/task.ts → task.ts} +0 -0
  82. /package/src/{utils → tw}/tw-utils.ts +0 -0
@@ -1,94 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- const axios_1 = __importDefault(require("axios"));
40
- const tw_wallet_1 = require("./tw-wallet");
41
- const secrets = __importStar(require("./secrets"));
42
- jest.mock('axios');
43
- jest.mock('opticedge-cloud-utils');
44
- jest.mock('./secrets');
45
- const mockedAxios = axios_1.default;
46
- const mockedGetSecret = secrets.getSecret;
47
- describe('pregenerateInAppWallet', () => {
48
- const mockProjectId = 'test-project';
49
- const mockClientId = 'test-client-id';
50
- const mockSecretKeyName = 'test-key';
51
- const mockEmail = 'user@example.com';
52
- const mockWalletAddress = '0xabc123';
53
- const mockSecretValue = 'mock-secret-key';
54
- beforeEach(() => {
55
- jest.clearAllMocks();
56
- });
57
- it('returns wallet address on success', async () => {
58
- mockedGetSecret.mockResolvedValue(mockSecretValue);
59
- mockedAxios.post.mockResolvedValue({
60
- data: {
61
- wallet: {
62
- address: mockWalletAddress
63
- }
64
- }
65
- });
66
- const result = await (0, tw_wallet_1.pregenerateInAppWallet)(mockProjectId, mockClientId, mockSecretKeyName, mockEmail);
67
- expect(mockedGetSecret).toHaveBeenCalledWith(mockProjectId, mockSecretKeyName);
68
- expect(mockedAxios.post).toHaveBeenCalledWith('https://in-app-wallet.thirdweb.com/api/v1/pregenerate', { strategy: 'email', email: mockEmail }, {
69
- headers: {
70
- 'x-secret-key': mockSecretValue,
71
- 'x-client-id': mockClientId,
72
- 'Content-Type': 'application/json'
73
- },
74
- timeout: 5000
75
- });
76
- expect(result).toBe(mockWalletAddress);
77
- });
78
- it('returns null if wallet.address is missing', async () => {
79
- mockedGetSecret.mockResolvedValue(mockSecretValue);
80
- mockedAxios.post.mockResolvedValue({
81
- data: {
82
- wallet: {} // Missing address
83
- }
84
- });
85
- const result = await (0, tw_wallet_1.pregenerateInAppWallet)(mockProjectId, mockClientId, mockSecretKeyName, mockEmail);
86
- expect(result).toBeNull();
87
- });
88
- it('returns null on axios error', async () => {
89
- mockedGetSecret.mockResolvedValue(mockSecretValue);
90
- mockedAxios.post.mockRejectedValue(new Error('Network error'));
91
- const result = await (0, tw_wallet_1.pregenerateInAppWallet)(mockProjectId, mockClientId, mockSecretKeyName, mockEmail);
92
- expect(result).toBeNull();
93
- });
94
- });
package/src/constants.ts DELETED
@@ -1,6 +0,0 @@
1
- import { PaymentEnvironment } from './types/payment'
2
-
3
- export const CHAIN_PAYMENTENV_MAP: Record<string, PaymentEnvironment> = {
4
- '80002': 'SANDBOX',
5
- '137': 'PRODUCTION'
6
- }
package/src/types/card.ts DELETED
@@ -1,82 +0,0 @@
1
- export enum CardApprovalStatus {
2
- Rescan = -2,
3
- Pending,
4
- Failed,
5
- Approved,
6
- Approving = 999
7
- }
8
-
9
- export enum CardGradingType {
10
- UNKNOWN = 0,
11
- COLLECTION = 1,
12
- ADDED = 2,
13
- SOLD = 3,
14
- CARD_CENTERING = 6
15
- }
16
-
17
- export type MarketReport = {
18
- data: string
19
- title: string
20
- price: {
21
- currency: string
22
- range: {
23
- min: number
24
- max: number
25
- }
26
- max: number
27
- }
28
- }
29
-
30
- export type Card = {
31
- _createdAt: number
32
- _updatedAt: number
33
- amountToReinvest: number
34
- approved?: CardApprovalStatus
35
- appraisalReport?: string
36
- assetID: string
37
- backImage: string
38
- backImageUncropped: string
39
- card_structure: number
40
- countryLanguage?: string
41
- cardType: string
42
- category: string
43
- centering_grading: number
44
- corner_grading: number
45
- edge_grading: number
46
- frontImage: string
47
- frontImageUncropped: string
48
- gifUrl?: string
49
- gradeDate: number
50
- grading: number
51
- grading_confidence: number
52
- grading_environment: number
53
- hp: number
54
- identifier: string
55
- isPulledFromPack: boolean
56
- isRead: boolean
57
- isSetCostOfCard: boolean
58
- isSold: boolean
59
- latitude: number
60
- longitude: number
61
- moneyEarn: number
62
- marketLink?: string
63
- marketReport?: MarketReport
64
- name: string
65
- note: string
66
- number: string
67
- priceHigh: number
68
- priceLow: number
69
- priceMarket: number
70
- priceValue: number
71
- releaseDate?: number
72
- resultInvisible: boolean
73
- saleNote: string
74
- series: string
75
- setName?: string
76
- surface_grading: number
77
- tcgLargeImageUrl: string
78
- tcgSmallImageUrl: string
79
- type: number
80
- typeOfGrading: CardGradingType
81
- userId: string
82
- }
@@ -1,4 +0,0 @@
1
- export type Message = {
2
- title: string
3
- body: string
4
- }
@@ -1 +0,0 @@
1
- export type PaymentEnvironment = 'SANDBOX' | 'PRODUCTION'
@@ -1,162 +0,0 @@
1
- import { PriceChartingPrice } from './pricecharting'
2
-
3
- export type TCGPlayerPrices = {
4
- low: number
5
- mid: number
6
- high: number
7
- market: number
8
- directLow: number
9
- }
10
-
11
- export type CardMarketPrices = {
12
- averageSellPrice: number
13
- lowPrice: number
14
- trendPrice: number
15
- germanProLow: number
16
- suggestedPrice: number
17
- reverseHoloSell: number
18
- reverseHoloLow: number
19
- reverseHoloTrend: number
20
- lowPriceExPlus: number
21
- avg1: number
22
- avg7: number
23
- avg30: number
24
- reverseHoloAvg1: number
25
- reverseHoloAvg7: number
26
- reverseHoloAvg30: number
27
- }
28
-
29
- export type PokemonTCGCard = {
30
- id: string
31
- name: string
32
- supertype: string
33
- subtypes: string[]
34
- level: string
35
- hp: string
36
- evolvesFrom: string
37
- evolvesTo: string[]
38
- rules: string[]
39
- ancientTrait: {
40
- name: string
41
- text: string
42
- }
43
- abilities: [
44
- {
45
- name: string
46
- text: string
47
- type: string
48
- }
49
- ]
50
- attacks: [
51
- {
52
- cost: string[]
53
- name: string
54
- text: string
55
- damage: string
56
- convertedEnergyCost: number
57
- }
58
- ]
59
- weaknesses: [
60
- {
61
- type: string
62
- value: string
63
- }
64
- ]
65
- resistances: [
66
- {
67
- type: string
68
- value: string
69
- }
70
- ]
71
- retreatCost: string[]
72
- convertedRetreatCost: number
73
- set: {
74
- id: string
75
- name: string
76
- series: string
77
- printedTotal: number
78
- total: number
79
- legalities: {
80
- unlimited: string
81
- standard: string
82
- expanded: string
83
- }
84
- ptcgoCode: string
85
- releaseDate: string
86
- updatedAt: string
87
- images: {
88
- symbol: string
89
- logo: string
90
- }
91
- }
92
- number: string
93
- artist: string
94
- rarity: string
95
- flavorText: string
96
- nationalPokedexNumbers: number[]
97
- legalities: [
98
- {
99
- standard: string
100
- expanded: string
101
- unlimited: string
102
- }
103
- ]
104
- regulationMark: string
105
- images: {
106
- small: string
107
- large: string
108
- }
109
- tcgplayer: {
110
- url: string
111
- updatedAt: string
112
- prices: {
113
- normal?: TCGPlayerPrices
114
- holofoil?: TCGPlayerPrices
115
- reverseHolofoil?: TCGPlayerPrices
116
- '1stEditionHolofoil'?: TCGPlayerPrices
117
- '1stEditionNormal'?: TCGPlayerPrices
118
- }
119
- }
120
- cardmarket: {
121
- url: string
122
- updatedAt: string
123
- prices: CardMarketPrices
124
- }
125
- pricecharting?: {
126
- id: number
127
- prices: PriceChartingPrice
128
- updatedAt: string
129
- deleted?: boolean
130
- }
131
- }
132
-
133
- export type PokemonCard = {
134
- _id: string
135
- card_id: string
136
- card_data: {
137
- name: string
138
- number: string
139
- setName: string
140
- setSeries: string
141
- }
142
- card: PokemonTCGCard
143
- pricehistory: [
144
- {
145
- date: string
146
- tcgplayer: {
147
- normal: TCGPlayerPrices | null
148
- holofoil: TCGPlayerPrices | null
149
- reverseHolofoil: TCGPlayerPrices | null
150
- firstEditionHolofoil: TCGPlayerPrices | null
151
- firstEditionNormal: TCGPlayerPrices | null
152
- }
153
- cardmarket: CardMarketPrices
154
- }
155
- ]
156
- pricecharting_id: number
157
- pricecharting_data: {
158
- consoleName: string
159
- productName: string
160
- releaseDate: string
161
- }
162
- }
@@ -1,42 +0,0 @@
1
- export type PriceChartingPrice = {
2
- loose: number | null
3
- cib: number | null
4
- new: number | null
5
- graded: number | null
6
- boxOnly: number | null
7
- manualOnly: number | null
8
- bgs10: number | null
9
- condition17: number | null
10
- condition18: number | null
11
- gamestop: number | null
12
- gamestopTrade: number | null
13
- retailLooseBuy: number | null
14
- retailLooseSell: number | null
15
- retailCibBuy: number | null
16
- retailCibSell: number | null
17
- retailNewBuy: number | null
18
- retailNewSell: number | null
19
- }
20
-
21
- export type PriceChartingPriceEntry = {
22
- date: string
23
- price: PriceChartingPrice
24
- }
25
-
26
- export type PriceChartingCard = {
27
- id: number
28
- consoleName: string
29
- productName: string
30
- upc: string
31
- genre: string
32
- tcgId: string
33
- asin: string
34
- epid: string
35
- releaseDate: string
36
- price: PriceChartingPrice
37
- priceHistory: PriceChartingPriceEntry[]
38
- salesVolume: number | null
39
- salesVolumeHistory: (number | null)[]
40
- updatedAt: string
41
- deleted?: boolean
42
- }
package/src/types/user.ts DELETED
@@ -1,38 +0,0 @@
1
- export enum UserCollectorType {
2
- 'Non-member' = -1,
3
- Elite,
4
- Rookie,
5
- Free
6
- }
7
-
8
- export type User = {
9
- cards: {
10
- count: number
11
- }
12
- collections: {
13
- count: number
14
- }
15
- email: string
16
- fcmTokens: Record<string, boolean>
17
- firstName: string
18
- fundAmount: number
19
- fundalert: number
20
- id: string
21
- insights: {
22
- count: number
23
- }
24
- isAppleUser: boolean
25
- isFacebookUser: boolean
26
- lastCardIndex: number
27
- lastGradingTime: number
28
- lastName: string
29
- soldCards: {
30
- count: number
31
- }
32
- thumbnail: string | undefined
33
- _collectorType: UserCollectorType
34
- _createdAt: number
35
- _currency: string
36
- _id: string
37
- _updatedAt: number
38
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes