@shopify/shopify-app-session-storage-redis 0.0.0-experimental-20240118200208
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/LICENSE.md +9 -0
- package/README.md +38 -0
- package/build/cjs/migrations.js +33 -0
- package/build/cjs/redis-connection.js +54 -0
- package/build/cjs/redis-migrator.js +39 -0
- package/build/cjs/redis.js +111 -0
- package/build/ts/migrations.d.ts +5 -0
- package/build/ts/migrations.d.ts.map +1 -0
- package/build/ts/migrations.js +83 -0
- package/build/ts/migrations.js.map +1 -0
- package/build/ts/redis-connection.d.ts +19 -0
- package/build/ts/redis-connection.d.ts.map +1 -0
- package/build/ts/redis-connection.js +96 -0
- package/build/ts/redis-connection.js.map +1 -0
- package/build/ts/redis-migrator.d.ts +10 -0
- package/build/ts/redis-migrator.d.ts.map +1 -0
- package/build/ts/redis-migrator.js +72 -0
- package/build/ts/redis-migrator.js.map +1 -0
- package/build/ts/redis.d.ts +27 -0
- package/build/ts/redis.d.ts.map +1 -0
- package/build/ts/redis.js +237 -0
- package/build/ts/redis.js.map +1 -0
- package/package.json +58 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022-present, Shopify Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Session Storage Adapter for Redis
|
|
2
|
+
|
|
3
|
+
This package implements the `SessionStorage` interface that works with an instance of [Redis](https://redis.io/).
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
import {shopifyApp} from '@shopify/shopify-app-express';
|
|
7
|
+
import {RedisSessionStorage} from '@shopify/shopify-app-session-storage-redis';
|
|
8
|
+
|
|
9
|
+
const shopify = shopifyApp({
|
|
10
|
+
sessionStorage: new RedisSessionStorage(
|
|
11
|
+
'redis://username:password@host/database',
|
|
12
|
+
),
|
|
13
|
+
// ...
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// OR
|
|
17
|
+
|
|
18
|
+
const shopify = shopifyApp({
|
|
19
|
+
sessionStorage: new RedisSessionStorage(
|
|
20
|
+
new URL('redis://username:password@host/database'),
|
|
21
|
+
),
|
|
22
|
+
// ...
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// OR
|
|
26
|
+
|
|
27
|
+
const shopify = shopifyApp({
|
|
28
|
+
sessionStorage: RedisSessionStorage.withCredentials(
|
|
29
|
+
'host.com',
|
|
30
|
+
'thedatabase',
|
|
31
|
+
'username',
|
|
32
|
+
'password',
|
|
33
|
+
),
|
|
34
|
+
// ...
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
If you prefer to use your own implementation of a session storage mechanism that is compatible with the `@shopify/shopify-app-express` package, see the [implementing session storage guide](https://github.com/Shopify/shopify-app-js/blob/main/packages/shopify-app-session-storage/implementing-session-storage.md).
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var shopifyApi = require('@shopify/shopify-api');
|
|
6
|
+
var shopifyAppSessionStorage = require('@shopify/shopify-app-session-storage');
|
|
7
|
+
|
|
8
|
+
const migrationList = [new shopifyAppSessionStorage.MigrationOperation(
|
|
9
|
+
// This migration name cannot be changed as it has already been released
|
|
10
|
+
'migrateToVersion1_0_1', migrateAddShopKeyToTrackSessionsByShop)];
|
|
11
|
+
|
|
12
|
+
// need to add shop keys with list of associated session keys to support
|
|
13
|
+
// the new findSessionsByShop in v2.x.x
|
|
14
|
+
async function migrateAddShopKeyToTrackSessionsByShop(connection) {
|
|
15
|
+
const shopsAndSessions = {};
|
|
16
|
+
const keys = await connection.keys('*');
|
|
17
|
+
for (const key of keys) {
|
|
18
|
+
if (key.startsWith(connection.sessionStorageIdentifier)) {
|
|
19
|
+
const session = shopifyApi.Session.fromPropertyArray(JSON.parse(await connection.get(key, false)));
|
|
20
|
+
if (!shopsAndSessions[session.shop]) {
|
|
21
|
+
shopsAndSessions[session.shop] = [];
|
|
22
|
+
}
|
|
23
|
+
shopsAndSessions[session.shop].push(key);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// eslint-disable-next-line guard-for-in
|
|
27
|
+
for (const shop in shopsAndSessions) {
|
|
28
|
+
await connection.set(shop, JSON.stringify(shopsAndSessions[shop]));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
exports.migrateAddShopKeyToTrackSessionsByShop = migrateAddShopKeyToTrackSessionsByShop;
|
|
33
|
+
exports.migrationList = migrationList;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var redis = require('redis');
|
|
6
|
+
|
|
7
|
+
class RedisConnection {
|
|
8
|
+
constructor(dbUrl, options, keyPrefix) {
|
|
9
|
+
this.sessionStorageIdentifier = void 0;
|
|
10
|
+
this.client = void 0;
|
|
11
|
+
this.eventHandler = (..._args) => {};
|
|
12
|
+
this.init(dbUrl, options);
|
|
13
|
+
this.sessionStorageIdentifier = keyPrefix;
|
|
14
|
+
}
|
|
15
|
+
query(_query, _params) {
|
|
16
|
+
throw new Error('Method not implemented. Use get(string, boolean) instead');
|
|
17
|
+
}
|
|
18
|
+
async connect() {
|
|
19
|
+
await this.client.connect();
|
|
20
|
+
}
|
|
21
|
+
async disconnect() {
|
|
22
|
+
await this.client.quit();
|
|
23
|
+
}
|
|
24
|
+
async keys(name) {
|
|
25
|
+
return this.client.keys(name);
|
|
26
|
+
}
|
|
27
|
+
async set(baseKey, value, addKeyPrefix = true) {
|
|
28
|
+
await this.client.set(this.buildKey(baseKey, addKeyPrefix), value);
|
|
29
|
+
}
|
|
30
|
+
async del(baseKey, addKeyPrefix = true) {
|
|
31
|
+
return this.client.del(this.buildKey(baseKey, addKeyPrefix));
|
|
32
|
+
}
|
|
33
|
+
async get(baseKey, addKeyPrefix = true) {
|
|
34
|
+
return this.client.get(this.buildKey(baseKey, addKeyPrefix));
|
|
35
|
+
}
|
|
36
|
+
generateFullKey(name) {
|
|
37
|
+
return `${this.sessionStorageIdentifier}_${name}`;
|
|
38
|
+
}
|
|
39
|
+
buildKey(baseKey, addKeyPrefix) {
|
|
40
|
+
return addKeyPrefix ? this.generateFullKey(baseKey) : baseKey;
|
|
41
|
+
}
|
|
42
|
+
init(dbUrl, options) {
|
|
43
|
+
this.client = redis.createClient({
|
|
44
|
+
...options,
|
|
45
|
+
url: dbUrl
|
|
46
|
+
});
|
|
47
|
+
this.client.on('error', this.eventHandler);
|
|
48
|
+
this.client.on('connect', this.eventHandler);
|
|
49
|
+
this.client.on('reconnecting', this.eventHandler);
|
|
50
|
+
this.client.on('ready', this.eventHandler);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
exports.RedisConnection = RedisConnection;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var shopifyAppSessionStorage = require('@shopify/shopify-app-session-storage');
|
|
6
|
+
|
|
7
|
+
class RedisSessionStorageMigrator extends shopifyAppSessionStorage.AbstractMigrationEngine {
|
|
8
|
+
constructor(dbConnection, opts = {}, migrations) {
|
|
9
|
+
// The name has already been decided whith the last migration
|
|
10
|
+
opts.migrationDBIdentifier = 'migrations';
|
|
11
|
+
super(dbConnection, opts, migrations);
|
|
12
|
+
}
|
|
13
|
+
async initMigrationPersistence() {
|
|
14
|
+
// nothing to do here
|
|
15
|
+
return Promise.resolve();
|
|
16
|
+
}
|
|
17
|
+
async hasMigrationBeenApplied(migrationName) {
|
|
18
|
+
var _migrations$get;
|
|
19
|
+
const migrations = await this.getMigrationRecords();
|
|
20
|
+
const found = (_migrations$get = migrations.get(migrationName)) !== null && _migrations$get !== void 0 ? _migrations$get : false;
|
|
21
|
+
return Promise.resolve(found);
|
|
22
|
+
}
|
|
23
|
+
async saveAppliedMigration(migrationName) {
|
|
24
|
+
const migrations = await this.getMigrationRecords();
|
|
25
|
+
migrations.set(migrationName, true);
|
|
26
|
+
this.connection.set(this.options.migrationDBIdentifier, JSON.stringify(Object.fromEntries(migrations)));
|
|
27
|
+
return Promise.resolve();
|
|
28
|
+
}
|
|
29
|
+
async getMigrationRecords() {
|
|
30
|
+
const migrationsRecord = await this.connection.get(this.options.migrationDBIdentifier);
|
|
31
|
+
let migrations = new Map();
|
|
32
|
+
if (migrationsRecord) {
|
|
33
|
+
migrations = new Map(Object.entries(JSON.parse(migrationsRecord)));
|
|
34
|
+
}
|
|
35
|
+
return Promise.resolve(migrations);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
exports.RedisSessionStorageMigrator = RedisSessionStorageMigrator;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var shopifyApi = require('@shopify/shopify-api');
|
|
6
|
+
var migrations = require('./migrations.js');
|
|
7
|
+
var redisConnection = require('./redis-connection.js');
|
|
8
|
+
var redisMigrator = require('./redis-migrator.js');
|
|
9
|
+
|
|
10
|
+
const defaultRedisSessionStorageOptions = {
|
|
11
|
+
sessionKeyPrefix: 'shopify_sessions',
|
|
12
|
+
migratorOptions: {
|
|
13
|
+
migrationDBIdentifier: 'migrations'
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
class RedisSessionStorage {
|
|
17
|
+
static withCredentials(host, db, username, password, opts) {
|
|
18
|
+
return new RedisSessionStorage(new URL(`redis://${encodeURIComponent(username)}:${encodeURIComponent(password)}@${host}/${db}`), opts);
|
|
19
|
+
}
|
|
20
|
+
constructor(dbUrl, opts = {}) {
|
|
21
|
+
this.ready = void 0;
|
|
22
|
+
this.internalInit = void 0;
|
|
23
|
+
this.options = void 0;
|
|
24
|
+
this.client = void 0;
|
|
25
|
+
this.migrator = void 0;
|
|
26
|
+
this.options = {
|
|
27
|
+
...defaultRedisSessionStorageOptions,
|
|
28
|
+
...opts
|
|
29
|
+
};
|
|
30
|
+
this.internalInit = this.init(typeof dbUrl === 'string' ? dbUrl : dbUrl.toString());
|
|
31
|
+
this.migrator = new redisMigrator.RedisSessionStorageMigrator(this.client, this.options.migratorOptions, migrations.migrationList);
|
|
32
|
+
this.ready = this.migrator.applyMigrations(this.internalInit);
|
|
33
|
+
}
|
|
34
|
+
async storeSession(session) {
|
|
35
|
+
await this.ready;
|
|
36
|
+
await this.client.set(session.id, JSON.stringify(session.toPropertyArray()));
|
|
37
|
+
await this.addKeyToShopList(session);
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
async loadSession(id) {
|
|
41
|
+
await this.ready;
|
|
42
|
+
let rawResult = await this.client.get(id);
|
|
43
|
+
if (!rawResult) return undefined;
|
|
44
|
+
rawResult = JSON.parse(rawResult);
|
|
45
|
+
return shopifyApi.Session.fromPropertyArray(rawResult);
|
|
46
|
+
}
|
|
47
|
+
async deleteSession(id) {
|
|
48
|
+
await this.ready;
|
|
49
|
+
const session = await this.loadSession(id);
|
|
50
|
+
if (session) {
|
|
51
|
+
await this.removeKeyFromShopList(session.shop, id);
|
|
52
|
+
await this.client.del(id);
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
async deleteSessions(ids) {
|
|
57
|
+
await this.ready;
|
|
58
|
+
await Promise.all(ids.map(id => this.deleteSession(id)));
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
async findSessionsByShop(shop) {
|
|
62
|
+
await this.ready;
|
|
63
|
+
const idKeysArrayString = await this.client.get(shop);
|
|
64
|
+
if (!idKeysArrayString) return [];
|
|
65
|
+
const idKeysArray = JSON.parse(idKeysArrayString);
|
|
66
|
+
const results = [];
|
|
67
|
+
for (const idKey of idKeysArray) {
|
|
68
|
+
const rawResult = await this.client.get(idKey, false);
|
|
69
|
+
if (!rawResult) continue;
|
|
70
|
+
const session = shopifyApi.Session.fromPropertyArray(JSON.parse(rawResult));
|
|
71
|
+
results.push(session);
|
|
72
|
+
}
|
|
73
|
+
return results;
|
|
74
|
+
}
|
|
75
|
+
async disconnect() {
|
|
76
|
+
await this.client.disconnect();
|
|
77
|
+
}
|
|
78
|
+
async addKeyToShopList(session) {
|
|
79
|
+
const shopKey = session.shop;
|
|
80
|
+
const idKey = this.client.generateFullKey(session.id);
|
|
81
|
+
const idKeysArrayString = await this.client.get(shopKey);
|
|
82
|
+
if (idKeysArrayString) {
|
|
83
|
+
const idKeysArray = JSON.parse(idKeysArrayString);
|
|
84
|
+
if (!idKeysArray.includes(idKey)) {
|
|
85
|
+
idKeysArray.push(idKey);
|
|
86
|
+
await this.client.set(shopKey, JSON.stringify(idKeysArray));
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
await this.client.set(shopKey, JSON.stringify([idKey]));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
async removeKeyFromShopList(shop, id) {
|
|
93
|
+
const shopKey = shop;
|
|
94
|
+
const idKey = this.client.generateFullKey(id);
|
|
95
|
+
const idKeysArrayString = await this.client.get(shopKey);
|
|
96
|
+
if (idKeysArrayString) {
|
|
97
|
+
const idKeysArray = JSON.parse(idKeysArrayString);
|
|
98
|
+
const index = idKeysArray.indexOf(idKey);
|
|
99
|
+
if (index > -1) {
|
|
100
|
+
idKeysArray.splice(index, 1);
|
|
101
|
+
await this.client.set(shopKey, JSON.stringify(idKeysArray));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async init(dbUrl) {
|
|
106
|
+
this.client = new redisConnection.RedisConnection(dbUrl, this.options, this.options.sessionKeyPrefix);
|
|
107
|
+
await this.client.connect();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
exports.RedisSessionStorage = RedisSessionStorage;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { MigrationOperation } from '@shopify/shopify-app-session-storage';
|
|
2
|
+
import { RedisConnection } from './redis-connection';
|
|
3
|
+
export declare const migrationList: MigrationOperation[];
|
|
4
|
+
export declare function migrateAddShopKeyToTrackSessionsByShop(connection: RedisConnection): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=migrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/migrations.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AAExE,OAAO,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAC;AAEnD,eAAO,MAAM,aAAa,sBAMzB,CAAC;AAIF,wBAAsB,sCAAsC,CAC1D,UAAU,EAAE,eAAe,GAC1B,OAAO,CAAC,IAAI,CAAC,CAkBf"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migrateAddShopKeyToTrackSessionsByShop = exports.migrationList = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var shopify_api_1 = require("@shopify/shopify-api");
|
|
6
|
+
var shopify_app_session_storage_1 = require("@shopify/shopify-app-session-storage");
|
|
7
|
+
exports.migrationList = [
|
|
8
|
+
new shopify_app_session_storage_1.MigrationOperation(
|
|
9
|
+
// This migration name cannot be changed as it has already been released
|
|
10
|
+
'migrateToVersion1_0_1', migrateAddShopKeyToTrackSessionsByShop),
|
|
11
|
+
];
|
|
12
|
+
// need to add shop keys with list of associated session keys to support
|
|
13
|
+
// the new findSessionsByShop in v2.x.x
|
|
14
|
+
function migrateAddShopKeyToTrackSessionsByShop(connection) {
|
|
15
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
16
|
+
var shopsAndSessions, keys, keys_1, keys_1_1, key, session, _a, _b, _c, _d, e_1_1, _e, _f, _g, _i, shop;
|
|
17
|
+
var e_1, _h;
|
|
18
|
+
return tslib_1.__generator(this, function (_j) {
|
|
19
|
+
switch (_j.label) {
|
|
20
|
+
case 0:
|
|
21
|
+
shopsAndSessions = {};
|
|
22
|
+
return [4 /*yield*/, connection.keys('*')];
|
|
23
|
+
case 1:
|
|
24
|
+
keys = _j.sent();
|
|
25
|
+
_j.label = 2;
|
|
26
|
+
case 2:
|
|
27
|
+
_j.trys.push([2, 7, 8, 9]);
|
|
28
|
+
keys_1 = tslib_1.__values(keys), keys_1_1 = keys_1.next();
|
|
29
|
+
_j.label = 3;
|
|
30
|
+
case 3:
|
|
31
|
+
if (!!keys_1_1.done) return [3 /*break*/, 6];
|
|
32
|
+
key = keys_1_1.value;
|
|
33
|
+
if (!key.startsWith(connection.sessionStorageIdentifier)) return [3 /*break*/, 5];
|
|
34
|
+
_b = (_a = shopify_api_1.Session).fromPropertyArray;
|
|
35
|
+
_d = (_c = JSON).parse;
|
|
36
|
+
return [4 /*yield*/, connection.get(key, false)];
|
|
37
|
+
case 4:
|
|
38
|
+
session = _b.apply(_a, [_d.apply(_c, [(_j.sent())])]);
|
|
39
|
+
if (!shopsAndSessions[session.shop]) {
|
|
40
|
+
shopsAndSessions[session.shop] = [];
|
|
41
|
+
}
|
|
42
|
+
shopsAndSessions[session.shop].push(key);
|
|
43
|
+
_j.label = 5;
|
|
44
|
+
case 5:
|
|
45
|
+
keys_1_1 = keys_1.next();
|
|
46
|
+
return [3 /*break*/, 3];
|
|
47
|
+
case 6: return [3 /*break*/, 9];
|
|
48
|
+
case 7:
|
|
49
|
+
e_1_1 = _j.sent();
|
|
50
|
+
e_1 = { error: e_1_1 };
|
|
51
|
+
return [3 /*break*/, 9];
|
|
52
|
+
case 8:
|
|
53
|
+
try {
|
|
54
|
+
if (keys_1_1 && !keys_1_1.done && (_h = keys_1.return)) _h.call(keys_1);
|
|
55
|
+
}
|
|
56
|
+
finally { if (e_1) throw e_1.error; }
|
|
57
|
+
return [7 /*endfinally*/];
|
|
58
|
+
case 9:
|
|
59
|
+
_e = shopsAndSessions;
|
|
60
|
+
_f = [];
|
|
61
|
+
for (_g in _e)
|
|
62
|
+
_f.push(_g);
|
|
63
|
+
_i = 0;
|
|
64
|
+
_j.label = 10;
|
|
65
|
+
case 10:
|
|
66
|
+
if (!(_i < _f.length)) return [3 /*break*/, 13];
|
|
67
|
+
_g = _f[_i];
|
|
68
|
+
if (!(_g in _e)) return [3 /*break*/, 12];
|
|
69
|
+
shop = _g;
|
|
70
|
+
return [4 /*yield*/, connection.set(shop, JSON.stringify(shopsAndSessions[shop]))];
|
|
71
|
+
case 11:
|
|
72
|
+
_j.sent();
|
|
73
|
+
_j.label = 12;
|
|
74
|
+
case 12:
|
|
75
|
+
_i++;
|
|
76
|
+
return [3 /*break*/, 10];
|
|
77
|
+
case 13: return [2 /*return*/];
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
exports.migrateAddShopKeyToTrackSessionsByShop = migrateAddShopKeyToTrackSessionsByShop;
|
|
83
|
+
//# sourceMappingURL=migrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrations.js","sourceRoot":"","sources":["../../src/migrations.ts"],"names":[],"mappings":";;;;AAAA,oDAA6C;AAC7C,oFAAwE;AAI3D,QAAA,aAAa,GAAG;IAC3B,IAAI,gDAAkB;IACpB,wEAAwE;IACxE,uBAAuB,EACvB,sCAAsC,CACvC;CACF,CAAC;AAEF,wEAAwE;AACxE,uCAAuC;AACvC,SAAsB,sCAAsC,CAC1D,UAA2B;;;;;;;oBAErB,gBAAgB,GAA8B,EAAE,CAAC;oBAC1C,qBAAM,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,EAAA;;oBAAjC,IAAI,GAAG,SAA0B;;;;oBACrB,SAAA,iBAAA,IAAI,CAAA;;;;oBAAX,GAAG;yBACR,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,wBAAwB,CAAC,EAAnD,wBAAmD;oBACrC,KAAA,CAAA,KAAA,qBAAO,CAAA,CAAC,iBAAiB,CAAA;oBACvC,KAAA,CAAA,KAAA,IAAI,CAAA,CAAC,KAAK,CAAA;oBAAE,qBAAM,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,EAAA;;oBADxC,OAAO,GAAG,cACd,cAAW,CAAC,SAAgC,CAAW,EAAC,EACzD;oBACD,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;wBACnC,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;qBACrC;oBACD,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;;;;;;;;;;;;;;;;;yBAI1B,gBAAgB;;;;;;;;;;;oBACjC,qBAAM,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAA;;oBAAlE,SAAkE,CAAC;;;;;;;;;CAEtE;AApBD,wFAoBC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RedisClientOptions } from 'redis';
|
|
2
|
+
import { DBConnection } from '@shopify/shopify-app-session-storage';
|
|
3
|
+
export declare class RedisConnection implements DBConnection {
|
|
4
|
+
sessionStorageIdentifier: string;
|
|
5
|
+
private client;
|
|
6
|
+
constructor(dbUrl: string, options: RedisClientOptions, keyPrefix: string);
|
|
7
|
+
query(_query: string, _params: any[]): Promise<any[]>;
|
|
8
|
+
connect(): Promise<void>;
|
|
9
|
+
disconnect(): Promise<void>;
|
|
10
|
+
keys(name: string): Promise<any>;
|
|
11
|
+
set(baseKey: string, value: any, addKeyPrefix?: boolean): Promise<void>;
|
|
12
|
+
del(baseKey: string, addKeyPrefix?: boolean): Promise<any>;
|
|
13
|
+
get(baseKey: string, addKeyPrefix?: boolean): Promise<any>;
|
|
14
|
+
generateFullKey(name: string): string;
|
|
15
|
+
private buildKey;
|
|
16
|
+
private init;
|
|
17
|
+
private eventHandler;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=redis-connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-connection.d.ts","sourceRoot":"","sources":["../../src/redis-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,kBAAkB,EAAC,MAAM,OAAO,CAAC;AACvD,OAAO,EAAC,YAAY,EAAC,MAAM,sCAAsC,CAAC;AAIlE,qBAAa,eAAgB,YAAW,YAAY;IAClD,wBAAwB,EAAE,MAAM,CAAC;IACjC,OAAO,CAAC,MAAM,CAAc;gBAEhB,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM;IAKzE,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAI/C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAIhC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,UAAO;IAIpD,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,UAAO,GAAG,OAAO,CAAC,GAAG,CAAC;IAIvD,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,UAAO,GAAG,OAAO,CAAC,GAAG,CAAC;IAI7D,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAIrC,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,IAAI;IAYZ,OAAO,CAAC,YAAY,CAA2B;CAChD"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedisConnection = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var redis_1 = require("redis");
|
|
6
|
+
var RedisConnection = /** @class */ (function () {
|
|
7
|
+
function RedisConnection(dbUrl, options, keyPrefix) {
|
|
8
|
+
this.eventHandler = function () {
|
|
9
|
+
var _args = [];
|
|
10
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11
|
+
_args[_i] = arguments[_i];
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
this.init(dbUrl, options);
|
|
15
|
+
this.sessionStorageIdentifier = keyPrefix;
|
|
16
|
+
}
|
|
17
|
+
RedisConnection.prototype.query = function (_query, _params) {
|
|
18
|
+
throw new Error('Method not implemented. Use get(string, boolean) instead');
|
|
19
|
+
};
|
|
20
|
+
RedisConnection.prototype.connect = function () {
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
22
|
+
return tslib_1.__generator(this, function (_a) {
|
|
23
|
+
switch (_a.label) {
|
|
24
|
+
case 0: return [4 /*yield*/, this.client.connect()];
|
|
25
|
+
case 1:
|
|
26
|
+
_a.sent();
|
|
27
|
+
return [2 /*return*/];
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
RedisConnection.prototype.disconnect = function () {
|
|
33
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
34
|
+
return tslib_1.__generator(this, function (_a) {
|
|
35
|
+
switch (_a.label) {
|
|
36
|
+
case 0: return [4 /*yield*/, this.client.quit()];
|
|
37
|
+
case 1:
|
|
38
|
+
_a.sent();
|
|
39
|
+
return [2 /*return*/];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
RedisConnection.prototype.keys = function (name) {
|
|
45
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
46
|
+
return tslib_1.__generator(this, function (_a) {
|
|
47
|
+
return [2 /*return*/, this.client.keys(name)];
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
RedisConnection.prototype.set = function (baseKey, value, addKeyPrefix) {
|
|
52
|
+
if (addKeyPrefix === void 0) { addKeyPrefix = true; }
|
|
53
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
54
|
+
return tslib_1.__generator(this, function (_a) {
|
|
55
|
+
switch (_a.label) {
|
|
56
|
+
case 0: return [4 /*yield*/, this.client.set(this.buildKey(baseKey, addKeyPrefix), value)];
|
|
57
|
+
case 1:
|
|
58
|
+
_a.sent();
|
|
59
|
+
return [2 /*return*/];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
RedisConnection.prototype.del = function (baseKey, addKeyPrefix) {
|
|
65
|
+
if (addKeyPrefix === void 0) { addKeyPrefix = true; }
|
|
66
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
67
|
+
return tslib_1.__generator(this, function (_a) {
|
|
68
|
+
return [2 /*return*/, this.client.del(this.buildKey(baseKey, addKeyPrefix))];
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
RedisConnection.prototype.get = function (baseKey, addKeyPrefix) {
|
|
73
|
+
if (addKeyPrefix === void 0) { addKeyPrefix = true; }
|
|
74
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
75
|
+
return tslib_1.__generator(this, function (_a) {
|
|
76
|
+
return [2 /*return*/, this.client.get(this.buildKey(baseKey, addKeyPrefix))];
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
RedisConnection.prototype.generateFullKey = function (name) {
|
|
81
|
+
return "".concat(this.sessionStorageIdentifier, "_").concat(name);
|
|
82
|
+
};
|
|
83
|
+
RedisConnection.prototype.buildKey = function (baseKey, addKeyPrefix) {
|
|
84
|
+
return addKeyPrefix ? this.generateFullKey(baseKey) : baseKey;
|
|
85
|
+
};
|
|
86
|
+
RedisConnection.prototype.init = function (dbUrl, options) {
|
|
87
|
+
this.client = (0, redis_1.createClient)(tslib_1.__assign(tslib_1.__assign({}, options), { url: dbUrl }));
|
|
88
|
+
this.client.on('error', this.eventHandler);
|
|
89
|
+
this.client.on('connect', this.eventHandler);
|
|
90
|
+
this.client.on('reconnecting', this.eventHandler);
|
|
91
|
+
this.client.on('ready', this.eventHandler);
|
|
92
|
+
};
|
|
93
|
+
return RedisConnection;
|
|
94
|
+
}());
|
|
95
|
+
exports.RedisConnection = RedisConnection;
|
|
96
|
+
//# sourceMappingURL=redis-connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-connection.js","sourceRoot":"","sources":["../../src/redis-connection.ts"],"names":[],"mappings":";;;;AAAA,+BAAuD;AAKvD;IAIE,yBAAY,K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sBAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,EAAC;;;KAC9D;IAED,yCAAe,GAAf,UAAgB,IAAY;QAC1B,OAAO,UAAG,IAAI,CAAC,wBAAwB,cAAI,IAAI,CAAE,CAAC;IACpD,CAAC;IAEO,kCAAQ,GAAhB,UAAiB,OAAe,EAAE,YAAqB;QACrD,OAAO,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAChE,CAAC;IAEO,8BAAI,GAAZ,UAAa,KAAa,EAAE,OAA2B;QACrD,IAAI,CAAC,MAAM,GAAG,IAAA,oBAAY,wCACrB,OAAO,KACV,GAAG,EAAE,KAAK,IACV,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3C,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAClD,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7C,CAAC;IAGH,sBAAC;AAAD,CAAC,AA1DD,IA0DC;AA1DY,0CAAe"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AbstractMigrationEngine, SessionStorageMigratorOptions, MigrationOperation } from '@shopify/shopify-app-session-storage';
|
|
2
|
+
import { RedisConnection } from './redis-connection';
|
|
3
|
+
export declare class RedisSessionStorageMigrator extends AbstractMigrationEngine<RedisConnection, SessionStorageMigratorOptions> {
|
|
4
|
+
constructor(dbConnection: RedisConnection, opts: Partial<SessionStorageMigratorOptions> | undefined, migrations: MigrationOperation[]);
|
|
5
|
+
initMigrationPersistence(): Promise<void>;
|
|
6
|
+
hasMigrationBeenApplied(migrationName: string): Promise<boolean>;
|
|
7
|
+
saveAppliedMigration(migrationName: string): Promise<void>;
|
|
8
|
+
private getMigrationRecords;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=redis-migrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-migrator.d.ts","sourceRoot":"","sources":["../../src/redis-migrator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,6BAA6B,EAC7B,kBAAkB,EACnB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAC;AAEnD,qBAAa,2BAA4B,SAAQ,uBAAuB,CACtE,eAAe,EACf,6BAA6B,CAC9B;gBAEG,YAAY,EAAE,eAAe,EAC7B,IAAI,oDAA6C,EACjD,UAAU,EAAE,kBAAkB,EAAE;IAO5B,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC;IAKzC,uBAAuB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOhE,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAYlD,mBAAmB;CAWlC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedisSessionStorageMigrator = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var shopify_app_session_storage_1 = require("@shopify/shopify-app-session-storage");
|
|
6
|
+
var RedisSessionStorageMigrator = /** @class */ (function (_super) {
|
|
7
|
+
tslib_1.__extends(RedisSessionStorageMigrator, _super);
|
|
8
|
+
function RedisSessionStorageMigrator(dbConnection, opts, migrations) {
|
|
9
|
+
if (opts === void 0) { opts = {}; }
|
|
10
|
+
// The name has already been decided whith the last migration
|
|
11
|
+
opts.migrationDBIdentifier = 'migrations';
|
|
12
|
+
return _super.call(this, dbConnection, opts, migrations) || this;
|
|
13
|
+
}
|
|
14
|
+
RedisSessionStorageMigrator.prototype.initMigrationPersistence = function () {
|
|
15
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
16
|
+
return tslib_1.__generator(this, function (_a) {
|
|
17
|
+
// nothing to do here
|
|
18
|
+
return [2 /*return*/, Promise.resolve()];
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
RedisSessionStorageMigrator.prototype.hasMigrationBeenApplied = function (migrationName) {
|
|
23
|
+
var _a;
|
|
24
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
25
|
+
var migrations, found;
|
|
26
|
+
return tslib_1.__generator(this, function (_b) {
|
|
27
|
+
switch (_b.label) {
|
|
28
|
+
case 0: return [4 /*yield*/, this.getMigrationRecords()];
|
|
29
|
+
case 1:
|
|
30
|
+
migrations = _b.sent();
|
|
31
|
+
found = (_a = migrations.get(migrationName)) !== null && _a !== void 0 ? _a : false;
|
|
32
|
+
return [2 /*return*/, Promise.resolve(found)];
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
RedisSessionStorageMigrator.prototype.saveAppliedMigration = function (migrationName) {
|
|
38
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
39
|
+
var migrations;
|
|
40
|
+
return tslib_1.__generator(this, function (_a) {
|
|
41
|
+
switch (_a.label) {
|
|
42
|
+
case 0: return [4 /*yield*/, this.getMigrationRecords()];
|
|
43
|
+
case 1:
|
|
44
|
+
migrations = _a.sent();
|
|
45
|
+
migrations.set(migrationName, true);
|
|
46
|
+
this.connection.set(this.options.migrationDBIdentifier, JSON.stringify(Object.fromEntries(migrations)));
|
|
47
|
+
return [2 /*return*/, Promise.resolve()];
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
RedisSessionStorageMigrator.prototype.getMigrationRecords = function () {
|
|
53
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
54
|
+
var migrationsRecord, migrations;
|
|
55
|
+
return tslib_1.__generator(this, function (_a) {
|
|
56
|
+
switch (_a.label) {
|
|
57
|
+
case 0: return [4 /*yield*/, this.connection.get(this.options.migrationDBIdentifier)];
|
|
58
|
+
case 1:
|
|
59
|
+
migrationsRecord = _a.sent();
|
|
60
|
+
migrations = new Map();
|
|
61
|
+
if (migrationsRecord) {
|
|
62
|
+
migrations = new Map(Object.entries(JSON.parse(migrationsRecord)));
|
|
63
|
+
}
|
|
64
|
+
return [2 /*return*/, Promise.resolve(migrations)];
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
return RedisSessionStorageMigrator;
|
|
70
|
+
}(shopify_app_session_storage_1.AbstractMigrationEngine));
|
|
71
|
+
exports.RedisSessionStorageMigrator = RedisSessionStorageMigrator;
|
|
72
|
+
//# sourceMappingURL=redis-migrator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-migrator.js","sourceRoot":"","sources":["../../src/redis-migrator.ts"],"names":[],"mappings":";;;;AAAA,oFAI8C;AAI9C;IAAiD,uDAGhD;IACC,qCACE,YAA6B,EAC7B,IAAiD,EACjD,UAAgC;QADhC,qBAAA,EAAA,SAAiD;QAGjD,6DAA6D;QAC7D,IAAI,CAAC,qBAAqB,GAAG,YAAY,CAAC;eAC1C,kBAAM,YAAY,EAAE,IAAI,EAAE,UAAU,CAAC;IACvC,CAAC;IAEK,8DAAwB,GAA9B;;;gBACE,qBAAqB;gBACrB,sBAAO,OAAO,CAAC,OAAO,EAAE,EAAC;;;KAC1B;IAEK,6DAAuB,GAA7B,UAA8B,aAAqB;;;;;;4BAC9B,qBAAM,IAAI,CAAC,mBAAmB,EAAE,EAAA;;wBAA7C,UAAU,GAAG,SAAgC;wBAC7C,KAAK,GAAG,MAAA,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,mCAAI,KAAK,CAAC;wBAErD,sBAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC;;;;KAC/B;IAEK,0DAAoB,GAA1B,UAA2B,aAAqB;;;;;4BAC3B,qBAAM,IAAI,CAAC,mBAAmB,EAAE,EAAA;;wBAA7C,UAAU,GAAG,SAAgC;wBACnD,UAAU,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;wBAEpC,IAAI,CAAC,UAAU,CAAC,GAAG,CACjB,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAClC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAC/C,CAAC;wBAEF,sBAAO,OAAO,CAAC,OAAO,EAAE,EAAC;;;;KAC1B;IAEa,yDAAmB,GAAjC;;;;;4BAC2B,qBAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAChD,IAAI,CAAC,OAAO,CAAC,qBAAqB,CACnC,EAAA;;wBAFK,gBAAgB,GAAG,SAExB;wBACG,UAAU,GAAyB,IAAI,GAAG,EAAE,CAAC;wBACjD,IAAI,gBAAgB,EAAE;4BACpB,UAAU,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;yBACpE;wBAED,sBAAO,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,EAAC;;;;KACpC;IACH,kCAAC;AAAD,CAAC,AAjDD,CAAiD,qDAAuB,GAiDvE;AAjDY,kEAA2B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RedisClientOptions } from 'redis';
|
|
2
|
+
import { Session } from '@shopify/shopify-api';
|
|
3
|
+
import { SessionStorage, SessionStorageMigratorOptions } from '@shopify/shopify-app-session-storage';
|
|
4
|
+
export interface RedisSessionStorageOptions extends RedisClientOptions {
|
|
5
|
+
sessionKeyPrefix: string;
|
|
6
|
+
onError?: (...args: any[]) => void;
|
|
7
|
+
migratorOptions?: SessionStorageMigratorOptions;
|
|
8
|
+
}
|
|
9
|
+
export declare class RedisSessionStorage implements SessionStorage {
|
|
10
|
+
static withCredentials(host: string, db: number, username: string, password: string, opts: Partial<RedisSessionStorageOptions>): RedisSessionStorage;
|
|
11
|
+
readonly ready: Promise<void>;
|
|
12
|
+
private internalInit;
|
|
13
|
+
private options;
|
|
14
|
+
private client;
|
|
15
|
+
private migrator;
|
|
16
|
+
constructor(dbUrl: URL | string, opts?: Partial<RedisSessionStorageOptions>);
|
|
17
|
+
storeSession(session: Session): Promise<boolean>;
|
|
18
|
+
loadSession(id: string): Promise<Session | undefined>;
|
|
19
|
+
deleteSession(id: string): Promise<boolean>;
|
|
20
|
+
deleteSessions(ids: string[]): Promise<boolean>;
|
|
21
|
+
findSessionsByShop(shop: string): Promise<Session[]>;
|
|
22
|
+
disconnect(): Promise<void>;
|
|
23
|
+
private addKeyToShopList;
|
|
24
|
+
private removeKeyFromShopList;
|
|
25
|
+
private init;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=redis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../src/redis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,OAAO,CAAC;AACzC,OAAO,EAAC,OAAO,EAAC,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EACL,cAAc,EACd,6BAA6B,EAE9B,MAAM,sCAAsC,CAAC;AAM9C,MAAM,WAAW,0BAA2B,SAAQ,kBAAkB;IACpE,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;IACnC,eAAe,CAAC,EAAE,6BAA6B,CAAC;CACjD;AAQD,qBAAa,mBAAoB,YAAW,cAAc;IACxD,MAAM,CAAC,eAAe,CACpB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,CAAC,0BAA0B,CAAC;IAY3C,SAAgB,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,QAAQ,CAAyB;gBAGvC,KAAK,EAAE,GAAG,GAAG,MAAM,EACnB,IAAI,GAAE,OAAO,CAAC,0BAA0B,CAAM;IAcnC,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAWhD,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAWrD,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAU3C,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAM/C,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAmBpD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;YAI1B,gBAAgB;YAiBhB,qBAAqB;YAgBrB,IAAI;CAQnB"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedisSessionStorage = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var shopify_api_1 = require("@shopify/shopify-api");
|
|
6
|
+
var migrations_1 = require("./migrations");
|
|
7
|
+
var redis_connection_1 = require("./redis-connection");
|
|
8
|
+
var redis_migrator_1 = require("./redis-migrator");
|
|
9
|
+
var defaultRedisSessionStorageOptions = {
|
|
10
|
+
sessionKeyPrefix: 'shopify_sessions',
|
|
11
|
+
migratorOptions: {
|
|
12
|
+
migrationDBIdentifier: 'migrations',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
var RedisSessionStorage = /** @class */ (function () {
|
|
16
|
+
function RedisSessionStorage(dbUrl, opts) {
|
|
17
|
+
if (opts === void 0) { opts = {}; }
|
|
18
|
+
this.options = tslib_1.__assign(tslib_1.__assign({}, defaultRedisSessionStorageOptions), opts);
|
|
19
|
+
this.internalInit = this.init(typeof dbUrl === 'string' ? dbUrl : dbUrl.toString());
|
|
20
|
+
this.migrator = new redis_migrator_1.RedisSessionStorageMigrator(this.client, this.options.migratorOptions, migrations_1.migrationList);
|
|
21
|
+
this.ready = this.migrator.applyMigrations(this.internalInit);
|
|
22
|
+
}
|
|
23
|
+
RedisSessionStorage.withCredentials = function (host, db, username, password, opts) {
|
|
24
|
+
return new RedisSessionStorage(new URL("redis://".concat(encodeURIComponent(username), ":").concat(encodeURIComponent(password), "@").concat(host, "/").concat(db)), opts);
|
|
25
|
+
};
|
|
26
|
+
RedisSessionStorage.prototype.storeSession = function (session) {
|
|
27
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
28
|
+
return tslib_1.__generator(this, function (_a) {
|
|
29
|
+
switch (_a.label) {
|
|
30
|
+
case 0: return [4 /*yield*/, this.ready];
|
|
31
|
+
case 1:
|
|
32
|
+
_a.sent();
|
|
33
|
+
return [4 /*yield*/, this.client.set(session.id, JSON.stringify(session.toPropertyArray()))];
|
|
34
|
+
case 2:
|
|
35
|
+
_a.sent();
|
|
36
|
+
return [4 /*yield*/, this.addKeyToShopList(session)];
|
|
37
|
+
case 3:
|
|
38
|
+
_a.sent();
|
|
39
|
+
return [2 /*return*/, true];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
RedisSessionStorage.prototype.loadSession = function (id) {
|
|
45
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
46
|
+
var rawResult;
|
|
47
|
+
return tslib_1.__generator(this, function (_a) {
|
|
48
|
+
switch (_a.label) {
|
|
49
|
+
case 0: return [4 /*yield*/, this.ready];
|
|
50
|
+
case 1:
|
|
51
|
+
_a.sent();
|
|
52
|
+
return [4 /*yield*/, this.client.get(id)];
|
|
53
|
+
case 2:
|
|
54
|
+
rawResult = _a.sent();
|
|
55
|
+
if (!rawResult)
|
|
56
|
+
return [2 /*return*/, undefined];
|
|
57
|
+
rawResult = JSON.parse(rawResult);
|
|
58
|
+
return [2 /*return*/, shopify_api_1.Session.fromPropertyArray(rawResult)];
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
RedisSessionStorage.prototype.deleteSession = function (id) {
|
|
64
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
65
|
+
var session;
|
|
66
|
+
return tslib_1.__generator(this, function (_a) {
|
|
67
|
+
switch (_a.label) {
|
|
68
|
+
case 0: return [4 /*yield*/, this.ready];
|
|
69
|
+
case 1:
|
|
70
|
+
_a.sent();
|
|
71
|
+
return [4 /*yield*/, this.loadSession(id)];
|
|
72
|
+
case 2:
|
|
73
|
+
session = _a.sent();
|
|
74
|
+
if (!session) return [3 /*break*/, 5];
|
|
75
|
+
return [4 /*yield*/, this.removeKeyFromShopList(session.shop, id)];
|
|
76
|
+
case 3:
|
|
77
|
+
_a.sent();
|
|
78
|
+
return [4 /*yield*/, this.client.del(id)];
|
|
79
|
+
case 4:
|
|
80
|
+
_a.sent();
|
|
81
|
+
_a.label = 5;
|
|
82
|
+
case 5: return [2 /*return*/, true];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
RedisSessionStorage.prototype.deleteSessions = function (ids) {
|
|
88
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
89
|
+
var _this = this;
|
|
90
|
+
return tslib_1.__generator(this, function (_a) {
|
|
91
|
+
switch (_a.label) {
|
|
92
|
+
case 0: return [4 /*yield*/, this.ready];
|
|
93
|
+
case 1:
|
|
94
|
+
_a.sent();
|
|
95
|
+
return [4 /*yield*/, Promise.all(ids.map(function (id) { return _this.deleteSession(id); }))];
|
|
96
|
+
case 2:
|
|
97
|
+
_a.sent();
|
|
98
|
+
return [2 /*return*/, true];
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
RedisSessionStorage.prototype.findSessionsByShop = function (shop) {
|
|
104
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
105
|
+
var idKeysArrayString, idKeysArray, results, idKeysArray_1, idKeysArray_1_1, idKey, rawResult, session, e_1_1;
|
|
106
|
+
var e_1, _a;
|
|
107
|
+
return tslib_1.__generator(this, function (_b) {
|
|
108
|
+
switch (_b.label) {
|
|
109
|
+
case 0: return [4 /*yield*/, this.ready];
|
|
110
|
+
case 1:
|
|
111
|
+
_b.sent();
|
|
112
|
+
return [4 /*yield*/, this.client.get(shop)];
|
|
113
|
+
case 2:
|
|
114
|
+
idKeysArrayString = _b.sent();
|
|
115
|
+
if (!idKeysArrayString)
|
|
116
|
+
return [2 /*return*/, []];
|
|
117
|
+
idKeysArray = JSON.parse(idKeysArrayString);
|
|
118
|
+
results = [];
|
|
119
|
+
_b.label = 3;
|
|
120
|
+
case 3:
|
|
121
|
+
_b.trys.push([3, 8, 9, 10]);
|
|
122
|
+
idKeysArray_1 = tslib_1.__values(idKeysArray), idKeysArray_1_1 = idKeysArray_1.next();
|
|
123
|
+
_b.label = 4;
|
|
124
|
+
case 4:
|
|
125
|
+
if (!!idKeysArray_1_1.done) return [3 /*break*/, 7];
|
|
126
|
+
idKey = idKeysArray_1_1.value;
|
|
127
|
+
return [4 /*yield*/, this.client.get(idKey, false)];
|
|
128
|
+
case 5:
|
|
129
|
+
rawResult = _b.sent();
|
|
130
|
+
if (!rawResult)
|
|
131
|
+
return [3 /*break*/, 6];
|
|
132
|
+
session = shopify_api_1.Session.fromPropertyArray(JSON.parse(rawResult));
|
|
133
|
+
results.push(session);
|
|
134
|
+
_b.label = 6;
|
|
135
|
+
case 6:
|
|
136
|
+
idKeysArray_1_1 = idKeysArray_1.next();
|
|
137
|
+
return [3 /*break*/, 4];
|
|
138
|
+
case 7: return [3 /*break*/, 10];
|
|
139
|
+
case 8:
|
|
140
|
+
e_1_1 = _b.sent();
|
|
141
|
+
e_1 = { error: e_1_1 };
|
|
142
|
+
return [3 /*break*/, 10];
|
|
143
|
+
case 9:
|
|
144
|
+
try {
|
|
145
|
+
if (idKeysArray_1_1 && !idKeysArray_1_1.done && (_a = idKeysArray_1.return)) _a.call(idKeysArray_1);
|
|
146
|
+
}
|
|
147
|
+
finally { if (e_1) throw e_1.error; }
|
|
148
|
+
return [7 /*endfinally*/];
|
|
149
|
+
case 10: return [2 /*return*/, results];
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
RedisSessionStorage.prototype.disconnect = function () {
|
|
155
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
156
|
+
return tslib_1.__generator(this, function (_a) {
|
|
157
|
+
switch (_a.label) {
|
|
158
|
+
case 0: return [4 /*yield*/, this.client.disconnect()];
|
|
159
|
+
case 1:
|
|
160
|
+
_a.sent();
|
|
161
|
+
return [2 /*return*/];
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
RedisSessionStorage.prototype.addKeyToShopList = function (session) {
|
|
167
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
168
|
+
var shopKey, idKey, idKeysArrayString, idKeysArray;
|
|
169
|
+
return tslib_1.__generator(this, function (_a) {
|
|
170
|
+
switch (_a.label) {
|
|
171
|
+
case 0:
|
|
172
|
+
shopKey = session.shop;
|
|
173
|
+
idKey = this.client.generateFullKey(session.id);
|
|
174
|
+
return [4 /*yield*/, this.client.get(shopKey)];
|
|
175
|
+
case 1:
|
|
176
|
+
idKeysArrayString = _a.sent();
|
|
177
|
+
if (!idKeysArrayString) return [3 /*break*/, 4];
|
|
178
|
+
idKeysArray = JSON.parse(idKeysArrayString);
|
|
179
|
+
if (!!idKeysArray.includes(idKey)) return [3 /*break*/, 3];
|
|
180
|
+
idKeysArray.push(idKey);
|
|
181
|
+
return [4 /*yield*/, this.client.set(shopKey, JSON.stringify(idKeysArray))];
|
|
182
|
+
case 2:
|
|
183
|
+
_a.sent();
|
|
184
|
+
_a.label = 3;
|
|
185
|
+
case 3: return [3 /*break*/, 6];
|
|
186
|
+
case 4: return [4 /*yield*/, this.client.set(shopKey, JSON.stringify([idKey]))];
|
|
187
|
+
case 5:
|
|
188
|
+
_a.sent();
|
|
189
|
+
_a.label = 6;
|
|
190
|
+
case 6: return [2 /*return*/];
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
RedisSessionStorage.prototype.removeKeyFromShopList = function (shop, id) {
|
|
196
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
197
|
+
var shopKey, idKey, idKeysArrayString, idKeysArray, index;
|
|
198
|
+
return tslib_1.__generator(this, function (_a) {
|
|
199
|
+
switch (_a.label) {
|
|
200
|
+
case 0:
|
|
201
|
+
shopKey = shop;
|
|
202
|
+
idKey = this.client.generateFullKey(id);
|
|
203
|
+
return [4 /*yield*/, this.client.get(shopKey)];
|
|
204
|
+
case 1:
|
|
205
|
+
idKeysArrayString = _a.sent();
|
|
206
|
+
if (!idKeysArrayString) return [3 /*break*/, 3];
|
|
207
|
+
idKeysArray = JSON.parse(idKeysArrayString);
|
|
208
|
+
index = idKeysArray.indexOf(idKey);
|
|
209
|
+
if (!(index > -1)) return [3 /*break*/, 3];
|
|
210
|
+
idKeysArray.splice(index, 1);
|
|
211
|
+
return [4 /*yield*/, this.client.set(shopKey, JSON.stringify(idKeysArray))];
|
|
212
|
+
case 2:
|
|
213
|
+
_a.sent();
|
|
214
|
+
_a.label = 3;
|
|
215
|
+
case 3: return [2 /*return*/];
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
RedisSessionStorage.prototype.init = function (dbUrl) {
|
|
221
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
222
|
+
return tslib_1.__generator(this, function (_a) {
|
|
223
|
+
switch (_a.label) {
|
|
224
|
+
case 0:
|
|
225
|
+
this.client = new redis_connection_1.RedisConnection(dbUrl, this.options, this.options.sessionKeyPrefix);
|
|
226
|
+
return [4 /*yield*/, this.client.connect()];
|
|
227
|
+
case 1:
|
|
228
|
+
_a.sent();
|
|
229
|
+
return [2 /*return*/];
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
return RedisSessionStorage;
|
|
235
|
+
}());
|
|
236
|
+
exports.RedisSessionStorage = RedisSessionStorage;
|
|
237
|
+
//# sourceMappingURL=redis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.js","sourceRoot":"","sources":["../../src/redis.ts"],"names":[],"mappings":";;;;AACA,oDAA6C;AAO7C,2CAA2C;AAC3C,uDAAmD;AACnD,mDAA6D;AAO7D,IAAM,iCAAiC,GAA+B;IACpE,gBAAgB,EAAE,kBAAkB;IACpC,eAAe,EAAE;QACf,qBAAqB,EAAE,YAAY;KACpC;CACF,CAAC;AAEF;IAwBE,6BACE,KAAmB,EACnB,IAA8C;QAA9C,qBAAA,EAAA,SAA8C;QAE9C,IAAI,CAAC,OAAO,yCAAO,iCAAiC,GAAK,IAAI,CAAC,CAAC;QAC/D,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,IAAI,CAC3B,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CACrD,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,IAAI,4CAA2B,CAC7C,IA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IAAI,CAAC;wBACf,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;wBACpB,qBAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,EAAA;;wBAAlD,iBAAiB,GAAG,SAA8B;6BAEpD,iBAAiB,EAAjB,wBAAiB;wBACb,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;wBAC5C,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;6BAErC,CAAA,KAAK,GAAG,CAAC,CAAC,CAAA,EAAV,wBAAU;wBACZ,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;wBAC7B,qBAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,EAAA;;wBAA3D,SAA2D,CAAC;;;;;;KAGjE;IAEa,kCAAI,GAAlB,UAAmB,KAAa;;;;;wBAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,kCAAe,CAC/B,KAAK,EACL,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAC9B,CAAC;wBACF,qBAAM,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAA;;wBAA3B,SAA2B,CAAC;;;;;KAC7B;IACH,0BAAC;AAAD,CAAC,AA9ID,IA8IC;AA9IY,kDAAmB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shopify/shopify-app-session-storage-redis",
|
|
3
|
+
"version": "0.0.0-experimental-20240118200208",
|
|
4
|
+
"description": "Shopify App Session Storage for Redis",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/Shopify/shopify-app-js.git"
|
|
8
|
+
},
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/Shopify/shopify-app-js/issues"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/Shopify/shopify-app-js/tree/main/packages/shopify-app-session-storage-redis",
|
|
13
|
+
"author": "Shopify Inc.",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"main": "./build/cjs/redis.js",
|
|
16
|
+
"types": "./build/ts/redis.d.ts",
|
|
17
|
+
"scripts": {},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"shopify",
|
|
23
|
+
"node",
|
|
24
|
+
"app",
|
|
25
|
+
"graphql",
|
|
26
|
+
"rest",
|
|
27
|
+
"webhook",
|
|
28
|
+
"Admin API",
|
|
29
|
+
"Storefront API",
|
|
30
|
+
"session storage",
|
|
31
|
+
"redis",
|
|
32
|
+
"Redis"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"redis": "^4.6.11",
|
|
36
|
+
"tslib": "^2.6.2"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@shopify/shopify-api": "^9.0.2",
|
|
40
|
+
"@shopify/shopify-app-session-storage": "0.0.0-experimental-20240118200208"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@shopify/eslint-plugin": "^42.1.0",
|
|
44
|
+
"@shopify/prettier-config": "^1.1.2",
|
|
45
|
+
"@shopify/shopify-app-session-storage-test-utils": "0.0.0-experimental-20240118200208",
|
|
46
|
+
"@types/jest": "^29.5.1",
|
|
47
|
+
"eslint": "^8.55.0",
|
|
48
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
49
|
+
"prettier": "^2.8.8",
|
|
50
|
+
"typescript": "4.9.5"
|
|
51
|
+
},
|
|
52
|
+
"files": [
|
|
53
|
+
"build/*",
|
|
54
|
+
"!bundle/*",
|
|
55
|
+
"!tsconfig.tsbuildinfo",
|
|
56
|
+
"!node_modules"
|
|
57
|
+
]
|
|
58
|
+
}
|