@nx-ddd/spreadsheet 0.0.0-PLACEHOLDER
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/README.md +11 -0
- package/google-sheet/client/client.d.ts +11 -0
- package/google-sheet/client/client.js +45 -0
- package/google-sheet/client/client.js.map +1 -0
- package/google-sheet/client/client.module.d.ts +2 -0
- package/google-sheet/client/client.module.js +15 -0
- package/google-sheet/client/client.module.js.map +1 -0
- package/google-sheet/client/index.d.ts +2 -0
- package/google-sheet/client/index.js +6 -0
- package/google-sheet/client/index.js.map +1 -0
- package/google-sheet/google-sheet.module.d.ts +2 -0
- package/google-sheet/google-sheet.module.js +14 -0
- package/google-sheet/google-sheet.module.js.map +1 -0
- package/google-sheet/index.d.ts +2 -0
- package/google-sheet/index.js +6 -0
- package/google-sheet/index.js.map +1 -0
- package/index.d.ts +2 -0
- package/index.js +6 -0
- package/index.js.map +1 -0
- package/package.json +14 -0
- package/spreadsheet.d.ts +1 -0
- package/spreadsheet.js +8 -0
- package/spreadsheet.js.map +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# spreadsheet
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Running unit tests
|
|
6
|
+
|
|
7
|
+
Run `nx test spreadsheet` to execute the unit tests via [Jest](https://jestjs.io).
|
|
8
|
+
|
|
9
|
+
## Running lint
|
|
10
|
+
|
|
11
|
+
Run `nx lint spreadsheet` to execute the lint via [ESLint](https://eslint.org/).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InjectionToken } from '@nx-ddd/core';
|
|
2
|
+
export declare const SERVICE_ACCOUNT: InjectionToken<unknown>;
|
|
3
|
+
export declare class GoogleSheetClient {
|
|
4
|
+
private serviceAccount;
|
|
5
|
+
constructor(serviceAccount: any);
|
|
6
|
+
private getDoc;
|
|
7
|
+
writeSheet(sheetId: string, sheetName: any, data: {
|
|
8
|
+
[key: string]: string | number | boolean;
|
|
9
|
+
}[]): Promise<void>;
|
|
10
|
+
readSheet(sheetId: string, sheetName: string): Promise<any>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GoogleSheetClient = exports.SERVICE_ACCOUNT = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const core_1 = require("@nx-ddd/core");
|
|
6
|
+
const google_spreadsheet_1 = require("google-spreadsheet");
|
|
7
|
+
exports.SERVICE_ACCOUNT = new core_1.InjectionToken('[@nx-ddd/spreadsheet] Service Account');
|
|
8
|
+
let GoogleSheetClient = class GoogleSheetClient {
|
|
9
|
+
constructor(serviceAccount) {
|
|
10
|
+
this.serviceAccount = serviceAccount;
|
|
11
|
+
}
|
|
12
|
+
getDoc(id) {
|
|
13
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
const doc = new google_spreadsheet_1.GoogleSpreadsheet(id);
|
|
15
|
+
yield doc.useServiceAccountAuth(this.serviceAccount);
|
|
16
|
+
yield doc.loadInfo();
|
|
17
|
+
return doc;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
writeSheet(sheetId, sheetName, data) {
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const doc = yield this.getDoc(sheetId);
|
|
23
|
+
const sheet = doc.sheetsByTitle[sheetName];
|
|
24
|
+
yield sheet.clear();
|
|
25
|
+
if (!data.length)
|
|
26
|
+
return;
|
|
27
|
+
yield sheet.setHeaderRow(Object.keys(data[0]));
|
|
28
|
+
yield sheet.addRows(data, { raw: false, insert: false });
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
readSheet(sheetId, sheetName) {
|
|
32
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const doc = yield this.getDoc(sheetId);
|
|
34
|
+
const sheet = doc.sheetsByTitle[sheetName];
|
|
35
|
+
return sheet.getRows();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
GoogleSheetClient = tslib_1.__decorate([
|
|
40
|
+
(0, core_1.Injectable)(),
|
|
41
|
+
tslib_1.__param(0, (0, core_1.Inject)(exports.SERVICE_ACCOUNT)),
|
|
42
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
43
|
+
], GoogleSheetClient);
|
|
44
|
+
exports.GoogleSheetClient = GoogleSheetClient;
|
|
45
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../../packages/@nx-ddd/spreadsheet/src/lib/google-sheet/client/client.ts"],"names":[],"mappings":";;;;AAAA,uCAAkE;AAClE,2DAAuD;AAE1C,QAAA,eAAe,GAAG,IAAI,qBAAc,CAAC,uCAAuC,CAAC,CAAC;AAGpF,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAE5B,YACmC,cAAmB;QAAnB,mBAAc,GAAd,cAAc,CAAK;IAClD,CAAC;IAES,MAAM,CAAC,EAAU;;YAC7B,MAAM,GAAG,GAAG,IAAI,sCAAiB,CAAC,EAAE,CAAC,CAAC;YACtC,MAAM,GAAG,CAAC,qBAAqB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YACrD,MAAM,GAAG,CAAC,QAAQ,EAAE,CAAC;YACrB,OAAO,GAAG,CAAC;QACb,CAAC;KAAA;IAEK,UAAU,CAAC,OAAe,EAAE,SAAS,EAAE,IAAkD;;YAC7F,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACvC,MAAM,KAAK,GAAG,GAAG,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;YAC3C,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;YACpB,IAAI,CAAC,IAAI,CAAC,MAAM;gBAAE,OAAO;YACzB,MAAM,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC/C,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAC,CAAC,CAAC;QACzD,CAAC;KAAA;IAEK,SAAS,CAAC,OAAe,EAAE,SAAiB;;YAChD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACvC,MAAM,KAAK,GAAG,GAAG,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;YAC3C,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC;KAAA;CACF,CAAA;AA3BY,iBAAiB;IAD7B,IAAA,iBAAU,GAAE;IAIR,mBAAA,IAAA,aAAM,EAAC,uBAAe,CAAC,CAAA;;GAHf,iBAAiB,CA2B7B;AA3BY,8CAAiB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GoogleSheetClientModule = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const core_1 = require("@nx-ddd/core");
|
|
6
|
+
const client_1 = require("./client");
|
|
7
|
+
let GoogleSheetClientModule = class GoogleSheetClientModule {
|
|
8
|
+
};
|
|
9
|
+
GoogleSheetClientModule = tslib_1.__decorate([
|
|
10
|
+
(0, core_1.NxModule)({
|
|
11
|
+
providers: [client_1.GoogleSheetClient],
|
|
12
|
+
})
|
|
13
|
+
], GoogleSheetClientModule);
|
|
14
|
+
exports.GoogleSheetClientModule = GoogleSheetClientModule;
|
|
15
|
+
//# sourceMappingURL=client.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.module.js","sourceRoot":"","sources":["../../../../../../packages/@nx-ddd/spreadsheet/src/lib/google-sheet/client/client.module.ts"],"names":[],"mappings":";;;;AAAA,uCAAwC;AACxC,qCAA6C;AAKtC,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;CAAI,CAAA;AAA3B,uBAAuB;IAHnC,IAAA,eAAQ,EAAC;QACR,SAAS,EAAE,CAAC,0BAAiB,CAAC;KAC/B,CAAC;GACW,uBAAuB,CAAI;AAA3B,0DAAuB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/@nx-ddd/spreadsheet/src/lib/google-sheet/client/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgC;AAChC,mDAAyB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GoogleSheetModule = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const core_1 = require("@nx-ddd/core");
|
|
6
|
+
let GoogleSheetModule = class GoogleSheetModule {
|
|
7
|
+
};
|
|
8
|
+
GoogleSheetModule = tslib_1.__decorate([
|
|
9
|
+
(0, core_1.NxModule)({
|
|
10
|
+
imports: []
|
|
11
|
+
})
|
|
12
|
+
], GoogleSheetModule);
|
|
13
|
+
exports.GoogleSheetModule = GoogleSheetModule;
|
|
14
|
+
//# sourceMappingURL=google-sheet.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-sheet.module.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/spreadsheet/src/lib/google-sheet/google-sheet.module.ts"],"names":[],"mappings":";;;;AAAA,uCAAwC;AAKjC,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAAI,CAAA;AAArB,iBAAiB;IAH7B,IAAA,eAAQ,EAAC;QACR,OAAO,EAAE,EAAE;KACZ,CAAC;GACW,iBAAiB,CAAI;AAArB,8CAAiB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./client"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./google-sheet.module"), exports);
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/spreadsheet/src/lib/google-sheet/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,gEAAsC"}
|
package/index.d.ts
ADDED
package/index.js
ADDED
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/@nx-ddd/spreadsheet/src/lib/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B;AAC/B,wDAA8B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nx-ddd/spreadsheet",
|
|
3
|
+
"version": "0.0.0-PLACEHOLDER",
|
|
4
|
+
"main": "./index.js",
|
|
5
|
+
"types": "./index.d.ts",
|
|
6
|
+
"dependencies": {},
|
|
7
|
+
"peerDependencies": {
|
|
8
|
+
"@nx-ddd/core": "0.0.0-PLACEHOLDER",
|
|
9
|
+
"injection-js": "^2.4.0",
|
|
10
|
+
"reflect-metadata": "^0.1.13",
|
|
11
|
+
"google-spreadsheet": "^3.2.0",
|
|
12
|
+
"tslib": "^2.0.0"
|
|
13
|
+
}
|
|
14
|
+
}
|
package/spreadsheet.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function spreadsheet(): string;
|
package/spreadsheet.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spreadsheet.js","sourceRoot":"","sources":["../../../../packages/@nx-ddd/spreadsheet/src/lib/spreadsheet.ts"],"names":[],"mappings":";;;AAAA,SAAgB,WAAW;IACzB,OAAO,aAAa,CAAC;AACvB,CAAC;AAFD,kCAEC"}
|