opticedge-cloud-utils 1.0.45 → 1.1.1
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/package.json +47 -6
- package/src/db/mongo.ts +1 -1
- package/src/db/mongo2.ts +1 -1
- package/src/db/mongo3.ts +1 -1
- package/src/{utils/tw-wallet.ts → tw/wallet.ts} +1 -1
- package/{src/auth/verify.test.ts → tests/auth.test.ts} +1 -1
- package/{src → tests}/db/mongo.test.ts +4 -4
- package/{src → tests}/db/mongo2.test.ts +5 -5
- package/{src → tests}/db/mongo3.test.ts +5 -5
- package/{src/utils → tests}/env.test.ts +1 -1
- package/{src/utils → tests}/regex.test.ts +1 -1
- package/{src/utils → tests}/secrets.test.ts +1 -1
- package/{src/utils → tests}/task.test.ts +1 -1
- package/{src/utils/tw-utils.test.ts → tests/tw/utils.test.ts} +1 -1
- package/{src/utils/tw-wallet.test.ts → tests/tw/wallet.test.ts} +3 -4
- package/dist/auth/verify.d.ts +0 -7
- package/dist/auth/verify.js +0 -23
- package/dist/auth/verify.test.d.ts +0 -1
- package/dist/auth/verify.test.js +0 -79
- package/dist/constants.d.ts +0 -2
- package/dist/constants.js +0 -7
- package/dist/db/mongo.d.ts +0 -3
- package/dist/db/mongo.js +0 -27
- package/dist/db/mongo.test.d.ts +0 -1
- package/dist/db/mongo.test.js +0 -73
- package/dist/db/mongo2.d.ts +0 -4
- package/dist/db/mongo2.js +0 -30
- package/dist/db/mongo2.test.d.ts +0 -1
- package/dist/db/mongo2.test.js +0 -86
- package/dist/db/mongo3.d.ts +0 -6
- package/dist/db/mongo3.js +0 -39
- package/dist/db/mongo3.test.d.ts +0 -1
- package/dist/db/mongo3.test.js +0 -108
- package/dist/index.d.ts +0 -17
- package/dist/index.js +0 -33
- package/dist/types/card.d.ts +0 -79
- package/dist/types/card.js +0 -19
- package/dist/types/notify.d.ts +0 -4
- package/dist/types/notify.js +0 -2
- package/dist/types/payment.d.ts +0 -1
- package/dist/types/payment.js +0 -2
- package/dist/types/pokemontcg.d.ts +0 -158
- package/dist/types/pokemontcg.js +0 -2
- package/dist/types/pricecharting.d.ts +0 -40
- package/dist/types/pricecharting.js +0 -2
- package/dist/types/user.d.ts +0 -37
- package/dist/types/user.js +0 -10
- package/dist/utils/env.d.ts +0 -1
- package/dist/utils/env.js +0 -12
- package/dist/utils/env.test.d.ts +0 -1
- package/dist/utils/env.test.js +0 -17
- package/dist/utils/regex.d.ts +0 -1
- package/dist/utils/regex.js +0 -6
- package/dist/utils/regex.test.d.ts +0 -1
- package/dist/utils/regex.test.js +0 -22
- package/dist/utils/secrets.d.ts +0 -8
- package/dist/utils/secrets.js +0 -22
- package/dist/utils/secrets.test.d.ts +0 -1
- package/dist/utils/secrets.test.js +0 -38
- package/dist/utils/task.d.ts +0 -1
- package/dist/utils/task.js +0 -38
- package/dist/utils/task.test.d.ts +0 -1
- package/dist/utils/task.test.js +0 -67
- package/dist/utils/tw-utils.d.ts +0 -1
- package/dist/utils/tw-utils.js +0 -19
- package/dist/utils/tw-utils.test.d.ts +0 -1
- package/dist/utils/tw-utils.test.js +0 -26
- package/dist/utils/tw-wallet.d.ts +0 -1
- package/dist/utils/tw-wallet.js +0 -32
- package/dist/utils/tw-wallet.test.d.ts +0 -1
- package/dist/utils/tw-wallet.test.js +0 -94
- package/src/constants.ts +0 -6
- package/src/index.ts +0 -17
- package/src/types/card.ts +0 -82
- package/src/types/notify.ts +0 -4
- package/src/types/payment.ts +0 -1
- package/src/types/pokemontcg.ts +0 -162
- package/src/types/pricecharting.ts +0 -42
- package/src/types/user.ts +0 -38
- /package/src/{auth/verify.ts → auth.ts} +0 -0
- /package/src/{utils/env.ts → env.ts} +0 -0
- /package/src/{utils/regex.ts → regex.ts} +0 -0
- /package/src/{utils/secrets.ts → secrets.ts} +0 -0
- /package/src/{utils/task.ts → task.ts} +0 -0
- /package/src/{utils/tw-utils.ts → tw/utils.ts} +0 -0
package/dist/db/mongo3.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.__connectPromises = exports.__mongoClients = void 0;
|
|
4
|
-
exports.connectToMongo3 = connectToMongo3;
|
|
5
|
-
exports.getDb3 = getDb3;
|
|
6
|
-
exports.getCollection3 = getCollection3;
|
|
7
|
-
// Multi cluster safe util
|
|
8
|
-
const mongodb_1 = require("mongodb");
|
|
9
|
-
const secrets_1 = require("../utils/secrets");
|
|
10
|
-
const clients = new Map();
|
|
11
|
-
const connectPromises = new Map();
|
|
12
|
-
async function connectToMongo3(projectId, uriSecret) {
|
|
13
|
-
if (clients.has(uriSecret)) {
|
|
14
|
-
return clients.get(uriSecret);
|
|
15
|
-
}
|
|
16
|
-
if (!connectPromises.has(uriSecret)) {
|
|
17
|
-
const promise = (async () => {
|
|
18
|
-
const uri = await (0, secrets_1.getSecret)(projectId, uriSecret);
|
|
19
|
-
const client = new mongodb_1.MongoClient(uri);
|
|
20
|
-
await client.connect();
|
|
21
|
-
clients.set(uriSecret, client);
|
|
22
|
-
})();
|
|
23
|
-
connectPromises.set(uriSecret, promise);
|
|
24
|
-
}
|
|
25
|
-
await connectPromises.get(uriSecret);
|
|
26
|
-
return clients.get(uriSecret);
|
|
27
|
-
}
|
|
28
|
-
function getDb3(uriSecret, dbName) {
|
|
29
|
-
const client = clients.get(uriSecret);
|
|
30
|
-
if (!client) {
|
|
31
|
-
throw new Error(`Mongo client for secret "${uriSecret}" not initialized`);
|
|
32
|
-
}
|
|
33
|
-
return client.db(dbName);
|
|
34
|
-
}
|
|
35
|
-
function getCollection3(uriSecret, dbName, collectionName) {
|
|
36
|
-
return getDb3(uriSecret, dbName).collection(collectionName);
|
|
37
|
-
}
|
|
38
|
-
exports.__mongoClients = clients;
|
|
39
|
-
exports.__connectPromises = connectPromises;
|
package/dist/db/mongo3.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/db/mongo3.test.js
DELETED
|
@@ -1,108 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const mongo3_1 = require("./mongo3");
|
|
37
|
-
const mongodb_1 = require("mongodb");
|
|
38
|
-
const secretsModule = __importStar(require("../utils/secrets"));
|
|
39
|
-
jest.mock('mongodb');
|
|
40
|
-
jest.mock('../utils/secrets');
|
|
41
|
-
const mockDb = {
|
|
42
|
-
collection: jest.fn()
|
|
43
|
-
};
|
|
44
|
-
const mockConnect = jest.fn();
|
|
45
|
-
const mockClient = {
|
|
46
|
-
connect: mockConnect,
|
|
47
|
-
db: jest.fn().mockReturnValue(mockDb)
|
|
48
|
-
};
|
|
49
|
-
beforeEach(() => {
|
|
50
|
-
jest.clearAllMocks();
|
|
51
|
-
mongo3_1.__mongoClients.clear();
|
|
52
|
-
mongo3_1.__connectPromises.clear();
|
|
53
|
-
secretsModule.getSecret.mockResolvedValue('mongodb://mock-uri');
|
|
54
|
-
mongodb_1.MongoClient.mockImplementation(() => mockClient);
|
|
55
|
-
});
|
|
56
|
-
describe('MongoClientManager (multi-cluster)', () => {
|
|
57
|
-
const clusterASecret = 'clusterA-uri-secret';
|
|
58
|
-
const clusterBSecret = 'clusterB-uri-secret';
|
|
59
|
-
it('should connect and cache client for a single cluster', async () => {
|
|
60
|
-
await (0, mongo3_1.connectToMongo3)('test-project', clusterASecret);
|
|
61
|
-
expect(secretsModule.getSecret).toHaveBeenCalledWith('test-project', clusterASecret);
|
|
62
|
-
expect(mockConnect).toHaveBeenCalled();
|
|
63
|
-
const db = (0, mongo3_1.getDb3)(clusterASecret, 'test-db');
|
|
64
|
-
expect(mockClient.db).toHaveBeenCalledWith('test-db');
|
|
65
|
-
expect(db).toBe(mockDb);
|
|
66
|
-
});
|
|
67
|
-
it('should reuse client if already connected', async () => {
|
|
68
|
-
await (0, mongo3_1.connectToMongo3)('test-project', clusterASecret);
|
|
69
|
-
await (0, mongo3_1.connectToMongo3)('test-project', clusterASecret);
|
|
70
|
-
// getSecret and connect should only happen once
|
|
71
|
-
expect(secretsModule.getSecret).toHaveBeenCalledTimes(1);
|
|
72
|
-
expect(mockConnect).toHaveBeenCalledTimes(1);
|
|
73
|
-
});
|
|
74
|
-
it('should connect and cache separate clients for multiple clusters', async () => {
|
|
75
|
-
// Mock different URIs for 2 clusters
|
|
76
|
-
;
|
|
77
|
-
secretsModule.getSecret
|
|
78
|
-
.mockResolvedValueOnce('mongodb://mock-uri-A')
|
|
79
|
-
.mockResolvedValueOnce('mongodb://mock-uri-B');
|
|
80
|
-
await (0, mongo3_1.connectToMongo3)('test-project', clusterASecret);
|
|
81
|
-
await (0, mongo3_1.connectToMongo3)('test-project', clusterBSecret);
|
|
82
|
-
// Should call getSecret + connect twice (for 2 clusters)
|
|
83
|
-
expect(secretsModule.getSecret).toHaveBeenCalledTimes(2);
|
|
84
|
-
expect(secretsModule.getSecret).toHaveBeenCalledWith('test-project', clusterASecret);
|
|
85
|
-
expect(secretsModule.getSecret).toHaveBeenCalledWith('test-project', clusterBSecret);
|
|
86
|
-
expect(mockConnect).toHaveBeenCalledTimes(2);
|
|
87
|
-
});
|
|
88
|
-
it('should return a collection when client is initialized', async () => {
|
|
89
|
-
await (0, mongo3_1.connectToMongo3)('test-project', clusterASecret);
|
|
90
|
-
(0, mongo3_1.getCollection3)(clusterASecret, 'test-db', 'users');
|
|
91
|
-
expect(mockClient.db).toHaveBeenCalledWith('test-db');
|
|
92
|
-
expect(mockDb.collection).toHaveBeenCalledWith('users');
|
|
93
|
-
});
|
|
94
|
-
it('should throw error if client not initialized (getDb)', () => {
|
|
95
|
-
jest.isolateModules(() => {
|
|
96
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
97
|
-
const { getDb3 } = require('./mongo3');
|
|
98
|
-
expect(() => getDb3('unknown-uri-secret', 'some-db')).toThrow('Mongo client for secret "unknown-uri-secret" not initialized');
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
it('should throw error if client not initialized (getCollection)', () => {
|
|
102
|
-
jest.isolateModules(() => {
|
|
103
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
104
|
-
const { getCollection3 } = require('./mongo3');
|
|
105
|
-
expect(() => getCollection3('unknown-uri-secret', 'some-db', 'users')).toThrow('Mongo client for secret "unknown-uri-secret" not initialized');
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
});
|
package/dist/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export * from './auth/verify';
|
|
2
|
-
export * from './db/mongo';
|
|
3
|
-
export * from './db/mongo2';
|
|
4
|
-
export * from './db/mongo3';
|
|
5
|
-
export * from './types/card';
|
|
6
|
-
export * from './types/notify';
|
|
7
|
-
export * from './types/payment';
|
|
8
|
-
export * from './types/pokemontcg';
|
|
9
|
-
export * from './types/pricecharting';
|
|
10
|
-
export * from './types/user';
|
|
11
|
-
export * from './utils/env';
|
|
12
|
-
export * from './utils/regex';
|
|
13
|
-
export * from './utils/secrets';
|
|
14
|
-
export * from './utils/task';
|
|
15
|
-
export * from './utils/tw-utils';
|
|
16
|
-
export * from './utils/tw-wallet';
|
|
17
|
-
export * from './constants';
|
package/dist/index.js
DELETED
|
@@ -1,33 +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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./auth/verify"), exports);
|
|
18
|
-
__exportStar(require("./db/mongo"), exports);
|
|
19
|
-
__exportStar(require("./db/mongo2"), exports);
|
|
20
|
-
__exportStar(require("./db/mongo3"), exports);
|
|
21
|
-
__exportStar(require("./types/card"), exports);
|
|
22
|
-
__exportStar(require("./types/notify"), exports);
|
|
23
|
-
__exportStar(require("./types/payment"), exports);
|
|
24
|
-
__exportStar(require("./types/pokemontcg"), exports);
|
|
25
|
-
__exportStar(require("./types/pricecharting"), exports);
|
|
26
|
-
__exportStar(require("./types/user"), exports);
|
|
27
|
-
__exportStar(require("./utils/env"), exports);
|
|
28
|
-
__exportStar(require("./utils/regex"), exports);
|
|
29
|
-
__exportStar(require("./utils/secrets"), exports);
|
|
30
|
-
__exportStar(require("./utils/task"), exports);
|
|
31
|
-
__exportStar(require("./utils/tw-utils"), exports);
|
|
32
|
-
__exportStar(require("./utils/tw-wallet"), exports);
|
|
33
|
-
__exportStar(require("./constants"), exports);
|
package/dist/types/card.d.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
export declare enum CardApprovalStatus {
|
|
2
|
-
Rescan = -2,
|
|
3
|
-
Pending = -1,
|
|
4
|
-
Failed = 0,
|
|
5
|
-
Approved = 1,
|
|
6
|
-
Approving = 999
|
|
7
|
-
}
|
|
8
|
-
export declare enum CardGradingType {
|
|
9
|
-
UNKNOWN = 0,
|
|
10
|
-
COLLECTION = 1,
|
|
11
|
-
ADDED = 2,
|
|
12
|
-
SOLD = 3,
|
|
13
|
-
CARD_CENTERING = 6
|
|
14
|
-
}
|
|
15
|
-
export type MarketReport = {
|
|
16
|
-
data: string;
|
|
17
|
-
title: string;
|
|
18
|
-
price: {
|
|
19
|
-
currency: string;
|
|
20
|
-
range: {
|
|
21
|
-
min: number;
|
|
22
|
-
max: number;
|
|
23
|
-
};
|
|
24
|
-
max: number;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
export type Card = {
|
|
28
|
-
_createdAt: number;
|
|
29
|
-
_updatedAt: number;
|
|
30
|
-
amountToReinvest: number;
|
|
31
|
-
approved?: CardApprovalStatus;
|
|
32
|
-
appraisalReport?: string;
|
|
33
|
-
assetID: string;
|
|
34
|
-
backImage: string;
|
|
35
|
-
backImageUncropped: string;
|
|
36
|
-
card_structure: number;
|
|
37
|
-
countryLanguage?: string;
|
|
38
|
-
cardType: string;
|
|
39
|
-
category: string;
|
|
40
|
-
centering_grading: number;
|
|
41
|
-
corner_grading: number;
|
|
42
|
-
edge_grading: number;
|
|
43
|
-
frontImage: string;
|
|
44
|
-
frontImageUncropped: string;
|
|
45
|
-
gifUrl?: string;
|
|
46
|
-
gradeDate: number;
|
|
47
|
-
grading: number;
|
|
48
|
-
grading_confidence: number;
|
|
49
|
-
grading_environment: number;
|
|
50
|
-
hp: number;
|
|
51
|
-
identifier: string;
|
|
52
|
-
isPulledFromPack: boolean;
|
|
53
|
-
isRead: boolean;
|
|
54
|
-
isSetCostOfCard: boolean;
|
|
55
|
-
isSold: boolean;
|
|
56
|
-
latitude: number;
|
|
57
|
-
longitude: number;
|
|
58
|
-
moneyEarn: number;
|
|
59
|
-
marketLink?: string;
|
|
60
|
-
marketReport?: MarketReport;
|
|
61
|
-
name: string;
|
|
62
|
-
note: string;
|
|
63
|
-
number: string;
|
|
64
|
-
priceHigh: number;
|
|
65
|
-
priceLow: number;
|
|
66
|
-
priceMarket: number;
|
|
67
|
-
priceValue: number;
|
|
68
|
-
releaseDate?: number;
|
|
69
|
-
resultInvisible: boolean;
|
|
70
|
-
saleNote: string;
|
|
71
|
-
series: string;
|
|
72
|
-
setName?: string;
|
|
73
|
-
surface_grading: number;
|
|
74
|
-
tcgLargeImageUrl: string;
|
|
75
|
-
tcgSmallImageUrl: string;
|
|
76
|
-
type: number;
|
|
77
|
-
typeOfGrading: CardGradingType;
|
|
78
|
-
userId: string;
|
|
79
|
-
};
|
package/dist/types/card.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CardGradingType = exports.CardApprovalStatus = void 0;
|
|
4
|
-
var CardApprovalStatus;
|
|
5
|
-
(function (CardApprovalStatus) {
|
|
6
|
-
CardApprovalStatus[CardApprovalStatus["Rescan"] = -2] = "Rescan";
|
|
7
|
-
CardApprovalStatus[CardApprovalStatus["Pending"] = -1] = "Pending";
|
|
8
|
-
CardApprovalStatus[CardApprovalStatus["Failed"] = 0] = "Failed";
|
|
9
|
-
CardApprovalStatus[CardApprovalStatus["Approved"] = 1] = "Approved";
|
|
10
|
-
CardApprovalStatus[CardApprovalStatus["Approving"] = 999] = "Approving";
|
|
11
|
-
})(CardApprovalStatus || (exports.CardApprovalStatus = CardApprovalStatus = {}));
|
|
12
|
-
var CardGradingType;
|
|
13
|
-
(function (CardGradingType) {
|
|
14
|
-
CardGradingType[CardGradingType["UNKNOWN"] = 0] = "UNKNOWN";
|
|
15
|
-
CardGradingType[CardGradingType["COLLECTION"] = 1] = "COLLECTION";
|
|
16
|
-
CardGradingType[CardGradingType["ADDED"] = 2] = "ADDED";
|
|
17
|
-
CardGradingType[CardGradingType["SOLD"] = 3] = "SOLD";
|
|
18
|
-
CardGradingType[CardGradingType["CARD_CENTERING"] = 6] = "CARD_CENTERING";
|
|
19
|
-
})(CardGradingType || (exports.CardGradingType = CardGradingType = {}));
|
package/dist/types/notify.d.ts
DELETED
package/dist/types/notify.js
DELETED
package/dist/types/payment.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type PaymentEnvironment = 'SANDBOX' | 'PRODUCTION';
|
package/dist/types/payment.js
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { PriceChartingPrice } from './pricecharting';
|
|
2
|
-
export type TCGPlayerPrices = {
|
|
3
|
-
low: number;
|
|
4
|
-
mid: number;
|
|
5
|
-
high: number;
|
|
6
|
-
market: number;
|
|
7
|
-
directLow: number;
|
|
8
|
-
};
|
|
9
|
-
export type CardMarketPrices = {
|
|
10
|
-
averageSellPrice: number;
|
|
11
|
-
lowPrice: number;
|
|
12
|
-
trendPrice: number;
|
|
13
|
-
germanProLow: number;
|
|
14
|
-
suggestedPrice: number;
|
|
15
|
-
reverseHoloSell: number;
|
|
16
|
-
reverseHoloLow: number;
|
|
17
|
-
reverseHoloTrend: number;
|
|
18
|
-
lowPriceExPlus: number;
|
|
19
|
-
avg1: number;
|
|
20
|
-
avg7: number;
|
|
21
|
-
avg30: number;
|
|
22
|
-
reverseHoloAvg1: number;
|
|
23
|
-
reverseHoloAvg7: number;
|
|
24
|
-
reverseHoloAvg30: number;
|
|
25
|
-
};
|
|
26
|
-
export type PokemonTCGCard = {
|
|
27
|
-
id: string;
|
|
28
|
-
name: string;
|
|
29
|
-
supertype: string;
|
|
30
|
-
subtypes: string[];
|
|
31
|
-
level: string;
|
|
32
|
-
hp: string;
|
|
33
|
-
evolvesFrom: string;
|
|
34
|
-
evolvesTo: string[];
|
|
35
|
-
rules: string[];
|
|
36
|
-
ancientTrait: {
|
|
37
|
-
name: string;
|
|
38
|
-
text: string;
|
|
39
|
-
};
|
|
40
|
-
abilities: [
|
|
41
|
-
{
|
|
42
|
-
name: string;
|
|
43
|
-
text: string;
|
|
44
|
-
type: string;
|
|
45
|
-
}
|
|
46
|
-
];
|
|
47
|
-
attacks: [
|
|
48
|
-
{
|
|
49
|
-
cost: string[];
|
|
50
|
-
name: string;
|
|
51
|
-
text: string;
|
|
52
|
-
damage: string;
|
|
53
|
-
convertedEnergyCost: number;
|
|
54
|
-
}
|
|
55
|
-
];
|
|
56
|
-
weaknesses: [
|
|
57
|
-
{
|
|
58
|
-
type: string;
|
|
59
|
-
value: string;
|
|
60
|
-
}
|
|
61
|
-
];
|
|
62
|
-
resistances: [
|
|
63
|
-
{
|
|
64
|
-
type: string;
|
|
65
|
-
value: string;
|
|
66
|
-
}
|
|
67
|
-
];
|
|
68
|
-
retreatCost: string[];
|
|
69
|
-
convertedRetreatCost: number;
|
|
70
|
-
set: {
|
|
71
|
-
id: string;
|
|
72
|
-
name: string;
|
|
73
|
-
series: string;
|
|
74
|
-
printedTotal: number;
|
|
75
|
-
total: number;
|
|
76
|
-
legalities: {
|
|
77
|
-
unlimited: string;
|
|
78
|
-
standard: string;
|
|
79
|
-
expanded: string;
|
|
80
|
-
};
|
|
81
|
-
ptcgoCode: string;
|
|
82
|
-
releaseDate: string;
|
|
83
|
-
updatedAt: string;
|
|
84
|
-
images: {
|
|
85
|
-
symbol: string;
|
|
86
|
-
logo: string;
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
number: string;
|
|
90
|
-
artist: string;
|
|
91
|
-
rarity: string;
|
|
92
|
-
flavorText: string;
|
|
93
|
-
nationalPokedexNumbers: number[];
|
|
94
|
-
legalities: [
|
|
95
|
-
{
|
|
96
|
-
standard: string;
|
|
97
|
-
expanded: string;
|
|
98
|
-
unlimited: string;
|
|
99
|
-
}
|
|
100
|
-
];
|
|
101
|
-
regulationMark: string;
|
|
102
|
-
images: {
|
|
103
|
-
small: string;
|
|
104
|
-
large: string;
|
|
105
|
-
};
|
|
106
|
-
tcgplayer: {
|
|
107
|
-
url: string;
|
|
108
|
-
updatedAt: string;
|
|
109
|
-
prices: {
|
|
110
|
-
normal?: TCGPlayerPrices;
|
|
111
|
-
holofoil?: TCGPlayerPrices;
|
|
112
|
-
reverseHolofoil?: TCGPlayerPrices;
|
|
113
|
-
'1stEditionHolofoil'?: TCGPlayerPrices;
|
|
114
|
-
'1stEditionNormal'?: TCGPlayerPrices;
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
cardmarket: {
|
|
118
|
-
url: string;
|
|
119
|
-
updatedAt: string;
|
|
120
|
-
prices: CardMarketPrices;
|
|
121
|
-
};
|
|
122
|
-
pricecharting?: {
|
|
123
|
-
id: number;
|
|
124
|
-
prices: PriceChartingPrice;
|
|
125
|
-
updatedAt: string;
|
|
126
|
-
deleted?: boolean;
|
|
127
|
-
};
|
|
128
|
-
};
|
|
129
|
-
export type PokemonCard = {
|
|
130
|
-
_id: string;
|
|
131
|
-
card_id: string;
|
|
132
|
-
card_data: {
|
|
133
|
-
name: string;
|
|
134
|
-
number: string;
|
|
135
|
-
setName: string;
|
|
136
|
-
setSeries: string;
|
|
137
|
-
};
|
|
138
|
-
card: PokemonTCGCard;
|
|
139
|
-
pricehistory: [
|
|
140
|
-
{
|
|
141
|
-
date: string;
|
|
142
|
-
tcgplayer: {
|
|
143
|
-
normal: TCGPlayerPrices | null;
|
|
144
|
-
holofoil: TCGPlayerPrices | null;
|
|
145
|
-
reverseHolofoil: TCGPlayerPrices | null;
|
|
146
|
-
firstEditionHolofoil: TCGPlayerPrices | null;
|
|
147
|
-
firstEditionNormal: TCGPlayerPrices | null;
|
|
148
|
-
};
|
|
149
|
-
cardmarket: CardMarketPrices;
|
|
150
|
-
}
|
|
151
|
-
];
|
|
152
|
-
pricecharting_id: number;
|
|
153
|
-
pricecharting_data: {
|
|
154
|
-
consoleName: string;
|
|
155
|
-
productName: string;
|
|
156
|
-
releaseDate: string;
|
|
157
|
-
};
|
|
158
|
-
};
|
package/dist/types/pokemontcg.js
DELETED
|
@@ -1,40 +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
|
-
export type PriceChartingPriceEntry = {
|
|
21
|
-
date: string;
|
|
22
|
-
price: PriceChartingPrice;
|
|
23
|
-
};
|
|
24
|
-
export type PriceChartingCard = {
|
|
25
|
-
id: number;
|
|
26
|
-
consoleName: string;
|
|
27
|
-
productName: string;
|
|
28
|
-
upc: string;
|
|
29
|
-
genre: string;
|
|
30
|
-
tcgId: string;
|
|
31
|
-
asin: string;
|
|
32
|
-
epid: string;
|
|
33
|
-
releaseDate: string;
|
|
34
|
-
price: PriceChartingPrice;
|
|
35
|
-
priceHistory: PriceChartingPriceEntry[];
|
|
36
|
-
salesVolume: number | null;
|
|
37
|
-
salesVolumeHistory: (number | null)[];
|
|
38
|
-
updatedAt: string;
|
|
39
|
-
deleted?: boolean;
|
|
40
|
-
};
|
package/dist/types/user.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export declare enum UserCollectorType {
|
|
2
|
-
'Non-member' = -1,
|
|
3
|
-
Elite = 0,
|
|
4
|
-
Rookie = 1,
|
|
5
|
-
Free = 2
|
|
6
|
-
}
|
|
7
|
-
export type User = {
|
|
8
|
-
cards: {
|
|
9
|
-
count: number;
|
|
10
|
-
};
|
|
11
|
-
collections: {
|
|
12
|
-
count: number;
|
|
13
|
-
};
|
|
14
|
-
email: string;
|
|
15
|
-
fcmTokens: Record<string, boolean>;
|
|
16
|
-
firstName: string;
|
|
17
|
-
fundAmount: number;
|
|
18
|
-
fundalert: number;
|
|
19
|
-
id: string;
|
|
20
|
-
insights: {
|
|
21
|
-
count: number;
|
|
22
|
-
};
|
|
23
|
-
isAppleUser: boolean;
|
|
24
|
-
isFacebookUser: boolean;
|
|
25
|
-
lastCardIndex: number;
|
|
26
|
-
lastGradingTime: number;
|
|
27
|
-
lastName: string;
|
|
28
|
-
soldCards: {
|
|
29
|
-
count: number;
|
|
30
|
-
};
|
|
31
|
-
thumbnail: string | undefined;
|
|
32
|
-
_collectorType: UserCollectorType;
|
|
33
|
-
_createdAt: number;
|
|
34
|
-
_currency: string;
|
|
35
|
-
_id: string;
|
|
36
|
-
_updatedAt: number;
|
|
37
|
-
};
|
package/dist/types/user.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UserCollectorType = void 0;
|
|
4
|
-
var UserCollectorType;
|
|
5
|
-
(function (UserCollectorType) {
|
|
6
|
-
UserCollectorType[UserCollectorType["Non-member"] = -1] = "Non-member";
|
|
7
|
-
UserCollectorType[UserCollectorType["Elite"] = 0] = "Elite";
|
|
8
|
-
UserCollectorType[UserCollectorType["Rookie"] = 1] = "Rookie";
|
|
9
|
-
UserCollectorType[UserCollectorType["Free"] = 2] = "Free";
|
|
10
|
-
})(UserCollectorType || (exports.UserCollectorType = UserCollectorType = {}));
|
package/dist/utils/env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getEnv(name: string, fallback?: string): string;
|
package/dist/utils/env.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEnv = getEnv;
|
|
4
|
-
function getEnv(name, fallback) {
|
|
5
|
-
const value = process.env[name];
|
|
6
|
-
if (!value) {
|
|
7
|
-
if (fallback !== undefined)
|
|
8
|
-
return fallback;
|
|
9
|
-
throw new Error(`Missing env var ${name}`);
|
|
10
|
-
}
|
|
11
|
-
return value;
|
|
12
|
-
}
|
package/dist/utils/env.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/utils/env.test.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const env_1 = require("./env");
|
|
4
|
-
describe('getEnv', () => {
|
|
5
|
-
it('returns the value of an existing env var', () => {
|
|
6
|
-
process.env.TEST_KEY = 'test-value';
|
|
7
|
-
expect((0, env_1.getEnv)('TEST_KEY')).toBe('test-value');
|
|
8
|
-
});
|
|
9
|
-
it('returns fallback if env var is not set', () => {
|
|
10
|
-
delete process.env.OPTIONAL_KEY;
|
|
11
|
-
expect((0, env_1.getEnv)('OPTIONAL_KEY', 'default')).toBe('default');
|
|
12
|
-
});
|
|
13
|
-
it('throws error if env var is not set and no fallback provided', () => {
|
|
14
|
-
delete process.env.MISSING_KEY;
|
|
15
|
-
expect(() => (0, env_1.getEnv)('MISSING_KEY')).toThrow('Missing env var MISSING_KEY');
|
|
16
|
-
});
|
|
17
|
-
});
|
package/dist/utils/regex.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function escapeRegex(input: string): string;
|
package/dist/utils/regex.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/utils/regex.test.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const regex_1 = require("./regex");
|
|
4
|
-
describe('escapeRegex', () => {
|
|
5
|
-
it('escapes regex special characters', () => {
|
|
6
|
-
const input = 'Pikachu.$^*+?()[]{}|\\';
|
|
7
|
-
const expected = 'Pikachu\\.\\$\\^\\*\\+\\?\\(\\)\\[\\]\\{\\}\\|\\\\';
|
|
8
|
-
expect((0, regex_1.escapeRegex)(input)).toBe(expected);
|
|
9
|
-
});
|
|
10
|
-
it('returns same string if no special characters', () => {
|
|
11
|
-
const input = 'Charmander123';
|
|
12
|
-
expect((0, regex_1.escapeRegex)(input)).toBe('Charmander123');
|
|
13
|
-
});
|
|
14
|
-
it('works with empty string', () => {
|
|
15
|
-
expect((0, regex_1.escapeRegex)('')).toBe('');
|
|
16
|
-
});
|
|
17
|
-
it('does not escape regular alphanumerics or spaces', () => {
|
|
18
|
-
const input = 'Lt. Surge Pikachu';
|
|
19
|
-
const expected = 'Lt\\. Surge Pikachu';
|
|
20
|
-
expect((0, regex_1.escapeRegex)(input)).toBe(expected);
|
|
21
|
-
});
|
|
22
|
-
});
|
package/dist/utils/secrets.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the latest value of a Secret Manager secret.
|
|
3
|
-
*
|
|
4
|
-
* @param projectId – GCP project that owns the secret.
|
|
5
|
-
* @param secretName – Secret name (without version).
|
|
6
|
-
* @returns – UTF-8 string value.
|
|
7
|
-
*/
|
|
8
|
-
export declare function getSecret(projectId: string, secretName: string): Promise<string>;
|