@ciderjs/gasnuki 0.2.0 → 0.2.2
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 +13 -2
- package/dist/cli.cjs +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/promise.cjs +8 -3
- package/dist/promise.d.cts +4 -2
- package/dist/promise.d.mts +4 -2
- package/dist/promise.d.ts +4 -2
- package/dist/promise.mjs +8 -3
- package/dist/shared/{gasnuki.Yj84yCWz.cjs → gasnuki.D0Jm2dZh.cjs} +1 -1
- package/dist/shared/{gasnuki.C-MvXA42.mjs → gasnuki.DjqKPcXI.mjs} +1 -1
- package/package.json +7 -4
- package/{bin/typedef/clientside.d.ts → types/appsscript.ts} +2 -2
- package/bin/generate.ts +0 -11
package/README.md
CHANGED
|
@@ -26,11 +26,22 @@ pnpm add @ciderjs/gasnuki
|
|
|
26
26
|
npx @ciderjs/gasnuki
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
+
... or, add project's npm-script in `package.json`:
|
|
30
|
+
|
|
31
|
+
```jsonc
|
|
32
|
+
{
|
|
33
|
+
// others...
|
|
34
|
+
"scripts": {
|
|
35
|
+
"gas": "gasnuki"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
29
40
|
This will generate type definition files in the `types` directory by default.
|
|
30
41
|
|
|
31
42
|
2. Make sure the generated directory (default: `types`) is included in your `tsconfig.json`:
|
|
32
43
|
|
|
33
|
-
```
|
|
44
|
+
```jsonc
|
|
34
45
|
{
|
|
35
46
|
"compilerOptions": {
|
|
36
47
|
// ... your options ...
|
|
@@ -65,4 +76,4 @@ Bug reports and pull requests are welcome. Please use the `issues` or `pull requ
|
|
|
65
76
|
|
|
66
77
|
## License
|
|
67
78
|
|
|
68
|
-
MIT
|
|
79
|
+
MIT
|
package/dist/cli.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
const path = require('node:path');
|
|
5
5
|
const commander = require('commander');
|
|
6
|
-
const index = require('./shared/gasnuki.
|
|
6
|
+
const index = require('./shared/gasnuki.D0Jm2dZh.cjs');
|
|
7
7
|
require('chokidar');
|
|
8
8
|
require('consola');
|
|
9
9
|
require('node:fs');
|
|
@@ -24,7 +24,7 @@ function _interopNamespaceCompat(e) {
|
|
|
24
24
|
|
|
25
25
|
const path__namespace = /*#__PURE__*/_interopNamespaceCompat(path);
|
|
26
26
|
|
|
27
|
-
const version = "0.2.
|
|
27
|
+
const version = "0.2.2";
|
|
28
28
|
|
|
29
29
|
const parseArgs = async (command) => {
|
|
30
30
|
const cliOpts = command.opts();
|
package/dist/cli.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
|
-
import { l as loadConfig, g as generateTypes } from './shared/gasnuki.
|
|
4
|
+
import { l as loadConfig, g as generateTypes } from './shared/gasnuki.DjqKPcXI.mjs';
|
|
5
5
|
import 'chokidar';
|
|
6
6
|
import 'consola';
|
|
7
7
|
import 'node:fs';
|
|
8
8
|
import 'ts-morph';
|
|
9
9
|
import 'jiti';
|
|
10
10
|
|
|
11
|
-
const version = "0.2.
|
|
11
|
+
const version = "0.2.2";
|
|
12
12
|
|
|
13
13
|
const parseArgs = async (command) => {
|
|
14
14
|
const cliOpts = command.opts();
|
package/dist/index.cjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'node:path';
|
|
2
2
|
import 'chokidar';
|
|
3
3
|
import 'consola';
|
|
4
|
-
export { d as defineConfig, g as generateTypes } from './shared/gasnuki.
|
|
4
|
+
export { d as defineConfig, g as generateTypes } from './shared/gasnuki.DjqKPcXI.mjs';
|
|
5
5
|
import 'node:fs';
|
|
6
6
|
import 'ts-morph';
|
|
7
7
|
import 'jiti';
|
package/dist/promise.cjs
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const serverScripts = {
|
|
3
|
+
const getPromisedServerScripts = (mockupFunctions = {}) => {
|
|
4
|
+
const serverScripts = {
|
|
5
|
+
...mockupFunctions
|
|
6
|
+
};
|
|
7
|
+
if (!("google" in globalThis) || !google?.script?.run) {
|
|
8
|
+
return serverScripts;
|
|
9
|
+
}
|
|
5
10
|
for (const method of Object.keys(google.script.run)) {
|
|
6
11
|
if (["withSuccessHandler", "withFailureHandler", "withUserObject"].includes(
|
|
7
12
|
String(method)
|
|
@@ -15,4 +20,4 @@ const ServerScripts = () => {
|
|
|
15
20
|
return serverScripts;
|
|
16
21
|
};
|
|
17
22
|
|
|
18
|
-
exports.
|
|
23
|
+
exports.getPromisedServerScripts = getPromisedServerScripts;
|
package/dist/promise.d.cts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
type Promised<T> = {
|
|
2
2
|
[K in keyof T]: T[K] extends (...args: infer A) => infer R ? (...args: A) => Promise<R> : T[K];
|
|
3
3
|
};
|
|
4
|
-
|
|
4
|
+
type PartialScriptType<T> = Partial<Promised<T>>;
|
|
5
|
+
declare const getPromisedServerScripts: <T extends Record<string, (...args: any[]) => any> = Omit<typeof google.script.run, "withSuccessHandler" | "withFailureHandler" | "withUserObject">>(mockupFunctions?: PartialScriptType<T>) => Promised<T>;
|
|
5
6
|
|
|
6
|
-
export {
|
|
7
|
+
export { getPromisedServerScripts };
|
|
8
|
+
export type { PartialScriptType, Promised };
|
package/dist/promise.d.mts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
type Promised<T> = {
|
|
2
2
|
[K in keyof T]: T[K] extends (...args: infer A) => infer R ? (...args: A) => Promise<R> : T[K];
|
|
3
3
|
};
|
|
4
|
-
|
|
4
|
+
type PartialScriptType<T> = Partial<Promised<T>>;
|
|
5
|
+
declare const getPromisedServerScripts: <T extends Record<string, (...args: any[]) => any> = Omit<typeof google.script.run, "withSuccessHandler" | "withFailureHandler" | "withUserObject">>(mockupFunctions?: PartialScriptType<T>) => Promised<T>;
|
|
5
6
|
|
|
6
|
-
export {
|
|
7
|
+
export { getPromisedServerScripts };
|
|
8
|
+
export type { PartialScriptType, Promised };
|
package/dist/promise.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
type Promised<T> = {
|
|
2
2
|
[K in keyof T]: T[K] extends (...args: infer A) => infer R ? (...args: A) => Promise<R> : T[K];
|
|
3
3
|
};
|
|
4
|
-
|
|
4
|
+
type PartialScriptType<T> = Partial<Promised<T>>;
|
|
5
|
+
declare const getPromisedServerScripts: <T extends Record<string, (...args: any[]) => any> = Omit<typeof google.script.run, "withSuccessHandler" | "withFailureHandler" | "withUserObject">>(mockupFunctions?: PartialScriptType<T>) => Promised<T>;
|
|
5
6
|
|
|
6
|
-
export {
|
|
7
|
+
export { getPromisedServerScripts };
|
|
8
|
+
export type { PartialScriptType, Promised };
|
package/dist/promise.mjs
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
const
|
|
2
|
-
const serverScripts = {
|
|
1
|
+
const getPromisedServerScripts = (mockupFunctions = {}) => {
|
|
2
|
+
const serverScripts = {
|
|
3
|
+
...mockupFunctions
|
|
4
|
+
};
|
|
5
|
+
if (!("google" in globalThis) || !google?.script?.run) {
|
|
6
|
+
return serverScripts;
|
|
7
|
+
}
|
|
3
8
|
for (const method of Object.keys(google.script.run)) {
|
|
4
9
|
if (["withSuccessHandler", "withFailureHandler", "withUserObject"].includes(
|
|
5
10
|
String(method)
|
|
@@ -13,4 +18,4 @@ const ServerScripts = () => {
|
|
|
13
18
|
return serverScripts;
|
|
14
19
|
};
|
|
15
20
|
|
|
16
|
-
export {
|
|
21
|
+
export { getPromisedServerScripts };
|
|
@@ -23,7 +23,7 @@ const path__namespace = /*#__PURE__*/_interopNamespaceCompat(path);
|
|
|
23
23
|
const chokidar__namespace = /*#__PURE__*/_interopNamespaceCompat(chokidar);
|
|
24
24
|
const fs__namespace = /*#__PURE__*/_interopNamespaceCompat(fs);
|
|
25
25
|
|
|
26
|
-
const text = "type RemoveReturnType<T> = {\n [P in keyof T]: T[P] extends (...args: infer A) => any\n ? (...args: A) => void\n : T[P];\n};\n\ntype _AppsScriptRun = RemoveReturnType<ServerScripts> & {\n [key: string]: (...args: any[]) => any;\n withSuccessHandler: <T = string | number | boolean | undefined, U = any>(\n callback: (returnValues: T, userObject?: U) => void,\n ) => _AppsScriptRun;\n withFailureHandler: <U = any>(\n callback: (error: Error, userObject?: U) => void,\n ) => _AppsScriptRun;\n withUserObject: <U = any>(userObject: U) => _AppsScriptRun;\n};\n\ntype _AppsScriptHistoryFunction = (\n stateObject: object,\n params: object,\n hash: string,\n) => void;\n\ninterface _WebAppLovacationType {\n hash: string;\n parameter: Record<string, string>;\n parameters: Record<string, string[]>;\n}\n\nexport declare interface GoogleClientSideApi {\n script: {\n run: _AppsScriptRun;\n url: {\n getLocation: (\n callback: (location: _WebAppLovacationType) => void,\n ) => void;\n };\n history: {\n push: _AppsScriptHistoryFunction;\n replace: _AppsScriptHistoryFunction;\n setChangeHandler: (\n callback: (e: {\n state: object;\n location: _WebAppLovacationType;\n }) => void,\n ) => void;\n };\n };\n}\n\ndeclare global {\n const google: GoogleClientSideApi;\n}\n";
|
|
26
|
+
const text = "export type RemoveReturnType<T> = {\n [P in keyof T]: T[P] extends (...args: infer A) => any\n ? (...args: A) => void\n : T[P];\n};\n\ntype _AppsScriptRun = RemoveReturnType<ServerScripts> & {\n [key: string]: (...args: any[]) => any;\n withSuccessHandler: <T = string | number | boolean | undefined, U = any>(\n callback: (returnValues: T, userObject?: U) => void,\n ) => _AppsScriptRun;\n withFailureHandler: <U = any>(\n callback: (error: Error, userObject?: U) => void,\n ) => _AppsScriptRun;\n withUserObject: <U = any>(userObject: U) => _AppsScriptRun;\n};\n\ntype _AppsScriptHistoryFunction = (\n stateObject: object,\n params: object,\n hash: string,\n) => void;\n\ninterface _WebAppLovacationType {\n hash: string;\n parameter: Record<string, string>;\n parameters: Record<string, string[]>;\n}\n\nexport declare interface GoogleClientSideApi {\n script: {\n run: _AppsScriptRun;\n url: {\n getLocation: (\n callback: (location: _WebAppLovacationType) => void,\n ) => void;\n };\n history: {\n push: _AppsScriptHistoryFunction;\n replace: _AppsScriptHistoryFunction;\n setChangeHandler: (\n callback: (e: {\n state: object;\n location: _WebAppLovacationType;\n }) => void,\n ) => void;\n };\n };\n}\n\ndeclare global {\n const google: GoogleClientSideApi;\n}\n";
|
|
27
27
|
|
|
28
28
|
const getInterfaceMethodDefinition_ = (name, node) => {
|
|
29
29
|
const typeParameters = node.getTypeParameters?.() ?? [];
|
|
@@ -5,7 +5,7 @@ import * as fs from 'node:fs';
|
|
|
5
5
|
import { Project, SyntaxKind } from 'ts-morph';
|
|
6
6
|
import { createJiti } from 'jiti';
|
|
7
7
|
|
|
8
|
-
const text = "type RemoveReturnType<T> = {\n [P in keyof T]: T[P] extends (...args: infer A) => any\n ? (...args: A) => void\n : T[P];\n};\n\ntype _AppsScriptRun = RemoveReturnType<ServerScripts> & {\n [key: string]: (...args: any[]) => any;\n withSuccessHandler: <T = string | number | boolean | undefined, U = any>(\n callback: (returnValues: T, userObject?: U) => void,\n ) => _AppsScriptRun;\n withFailureHandler: <U = any>(\n callback: (error: Error, userObject?: U) => void,\n ) => _AppsScriptRun;\n withUserObject: <U = any>(userObject: U) => _AppsScriptRun;\n};\n\ntype _AppsScriptHistoryFunction = (\n stateObject: object,\n params: object,\n hash: string,\n) => void;\n\ninterface _WebAppLovacationType {\n hash: string;\n parameter: Record<string, string>;\n parameters: Record<string, string[]>;\n}\n\nexport declare interface GoogleClientSideApi {\n script: {\n run: _AppsScriptRun;\n url: {\n getLocation: (\n callback: (location: _WebAppLovacationType) => void,\n ) => void;\n };\n history: {\n push: _AppsScriptHistoryFunction;\n replace: _AppsScriptHistoryFunction;\n setChangeHandler: (\n callback: (e: {\n state: object;\n location: _WebAppLovacationType;\n }) => void,\n ) => void;\n };\n };\n}\n\ndeclare global {\n const google: GoogleClientSideApi;\n}\n";
|
|
8
|
+
const text = "export type RemoveReturnType<T> = {\n [P in keyof T]: T[P] extends (...args: infer A) => any\n ? (...args: A) => void\n : T[P];\n};\n\ntype _AppsScriptRun = RemoveReturnType<ServerScripts> & {\n [key: string]: (...args: any[]) => any;\n withSuccessHandler: <T = string | number | boolean | undefined, U = any>(\n callback: (returnValues: T, userObject?: U) => void,\n ) => _AppsScriptRun;\n withFailureHandler: <U = any>(\n callback: (error: Error, userObject?: U) => void,\n ) => _AppsScriptRun;\n withUserObject: <U = any>(userObject: U) => _AppsScriptRun;\n};\n\ntype _AppsScriptHistoryFunction = (\n stateObject: object,\n params: object,\n hash: string,\n) => void;\n\ninterface _WebAppLovacationType {\n hash: string;\n parameter: Record<string, string>;\n parameters: Record<string, string[]>;\n}\n\nexport declare interface GoogleClientSideApi {\n script: {\n run: _AppsScriptRun;\n url: {\n getLocation: (\n callback: (location: _WebAppLovacationType) => void,\n ) => void;\n };\n history: {\n push: _AppsScriptHistoryFunction;\n replace: _AppsScriptHistoryFunction;\n setChangeHandler: (\n callback: (e: {\n state: object;\n location: _WebAppLovacationType;\n }) => void,\n ) => void;\n };\n };\n}\n\ndeclare global {\n const google: GoogleClientSideApi;\n}\n";
|
|
9
9
|
|
|
10
10
|
const getInterfaceMethodDefinition_ = (name, node) => {
|
|
11
11
|
const typeParameters = node.getTypeParameters?.() ?? [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ciderjs/gasnuki",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Type definitions and utilities for Google Apps Script client-side API",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,13 +20,15 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
|
-
"
|
|
24
|
-
"dev": "pnpm prebuild && jiti src/cli.ts -p playground/react",
|
|
23
|
+
"generate": "jiti .bin/generate.ts",
|
|
24
|
+
"dev": "pnpm prebuild && jiti src/cli.ts -p playground/react -s src/server",
|
|
25
25
|
"start": "node dist/cli.mjs -p playground/react -s src/server",
|
|
26
26
|
"check": "biome check --write",
|
|
27
27
|
"build": "unbuild",
|
|
28
28
|
"test": "vitest run",
|
|
29
|
-
"prepare": "pnpm run check && pnpm run build"
|
|
29
|
+
"prepare": "pnpm run generate && pnpm run check && pnpm run test && pnpm run build",
|
|
30
|
+
"pg:react": "pnpm -C playground/react",
|
|
31
|
+
"pg:vue": "pnpm -C playground/vue3"
|
|
30
32
|
},
|
|
31
33
|
"keywords": ["google-apps-script", "typescript", "@google/clasp"],
|
|
32
34
|
"author": "ciderjs/luth",
|
|
@@ -50,6 +52,7 @@
|
|
|
50
52
|
"devDependencies": {
|
|
51
53
|
"@biomejs/biome": "^1.9.4",
|
|
52
54
|
"@types/node": "^22.15.29",
|
|
55
|
+
"@vitest/coverage-v8": "3.2.1",
|
|
53
56
|
"typescript": "^5.8.3",
|
|
54
57
|
"unbuild": "^3.5.0",
|
|
55
58
|
"vitest": "^3.2.1"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
type RemoveReturnType<T> = {
|
|
1
|
+
export type RemoveReturnType<T> = {
|
|
2
2
|
[P in keyof T]: T[P] extends (...args: infer A) => any
|
|
3
3
|
? (...args: A) => void
|
|
4
4
|
: T[P];
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
type _AppsScriptRun =
|
|
7
|
+
type _AppsScriptRun = {
|
|
8
8
|
[key: string]: (...args: any[]) => any;
|
|
9
9
|
withSuccessHandler: <T = string | number | boolean | undefined, U = any>(
|
|
10
10
|
callback: (returnValues: T, userObject?: U) => void,
|
package/bin/generate.ts
DELETED