@ciderjs/gasnuki 0.1.4 → 0.1.5
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/bin/typedef/clientside.d.ts +1 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/promise.cjs +18 -0
- package/dist/promise.d.cts +6 -0
- package/dist/promise.d.mts +6 -0
- package/dist/promise.d.ts +6 -0
- package/dist/promise.mjs +16 -0
- package/package.json +7 -2
|
@@ -5,6 +5,7 @@ type RemoveReturnType<T> = {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
type _AppsScriptRun = RemoveReturnType<ServerScripts> & {
|
|
8
|
+
[key: string]: (...args: any[]) => any;
|
|
8
9
|
withSuccessHandler: <T = string | number | boolean | undefined, U = any>(
|
|
9
10
|
callback: (returnValues: T, userObject?: U) => void,
|
|
10
11
|
) => _AppsScriptRun;
|
package/dist/cli.cjs
CHANGED
package/dist/cli.mjs
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -22,7 +22,7 @@ const path__namespace = /*#__PURE__*/_interopNamespaceCompat(path);
|
|
|
22
22
|
const chokidar__namespace = /*#__PURE__*/_interopNamespaceCompat(chokidar);
|
|
23
23
|
const fs__namespace = /*#__PURE__*/_interopNamespaceCompat(fs);
|
|
24
24
|
|
|
25
|
-
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 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";
|
|
25
|
+
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
26
|
|
|
27
27
|
const getInterfaceMethodDefinition_ = (name, node) => {
|
|
28
28
|
const typeParameters = node.getTypeParameters?.() ?? [];
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { consola } from 'consola';
|
|
|
4
4
|
import * as fs from 'node:fs';
|
|
5
5
|
import { Project, SyntaxKind } from 'ts-morph';
|
|
6
6
|
|
|
7
|
-
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 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";
|
|
7
|
+
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
8
|
|
|
9
9
|
const getInterfaceMethodDefinition_ = (name, node) => {
|
|
10
10
|
const typeParameters = node.getTypeParameters?.() ?? [];
|
package/dist/promise.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const ServerScripts = () => {
|
|
4
|
+
const serverScripts = {};
|
|
5
|
+
for (const method of Object.keys(google.script.run)) {
|
|
6
|
+
if (["withSuccessHandler", "withFailureHandler", "withUserObject"].includes(
|
|
7
|
+
String(method)
|
|
8
|
+
)) {
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
serverScripts[method] = (...args) => new Promise((resolve, reject) => {
|
|
12
|
+
google.script.run.withSuccessHandler(resolve).withFailureHandler(reject)[method](...args);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return serverScripts;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.ServerScripts = ServerScripts;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type Promised<T> = {
|
|
2
|
+
[K in keyof T]: T[K] extends (...args: infer A) => infer R ? (...args: A) => Promise<R> : T[K];
|
|
3
|
+
};
|
|
4
|
+
declare const ServerScripts: <T extends Record<string, (...args: any[]) => any> = Omit<Omit<Omit<typeof google.script.run, "withSuccessHandler">, "withFailureHandler">, "withUserObject">>() => Promised<T>;
|
|
5
|
+
|
|
6
|
+
export { ServerScripts };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type Promised<T> = {
|
|
2
|
+
[K in keyof T]: T[K] extends (...args: infer A) => infer R ? (...args: A) => Promise<R> : T[K];
|
|
3
|
+
};
|
|
4
|
+
declare const ServerScripts: <T extends Record<string, (...args: any[]) => any> = Omit<Omit<Omit<typeof google.script.run, "withSuccessHandler">, "withFailureHandler">, "withUserObject">>() => Promised<T>;
|
|
5
|
+
|
|
6
|
+
export { ServerScripts };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type Promised<T> = {
|
|
2
|
+
[K in keyof T]: T[K] extends (...args: infer A) => infer R ? (...args: A) => Promise<R> : T[K];
|
|
3
|
+
};
|
|
4
|
+
declare const ServerScripts: <T extends Record<string, (...args: any[]) => any> = Omit<Omit<Omit<typeof google.script.run, "withSuccessHandler">, "withFailureHandler">, "withUserObject">>() => Promised<T>;
|
|
5
|
+
|
|
6
|
+
export { ServerScripts };
|
package/dist/promise.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const ServerScripts = () => {
|
|
2
|
+
const serverScripts = {};
|
|
3
|
+
for (const method of Object.keys(google.script.run)) {
|
|
4
|
+
if (["withSuccessHandler", "withFailureHandler", "withUserObject"].includes(
|
|
5
|
+
String(method)
|
|
6
|
+
)) {
|
|
7
|
+
continue;
|
|
8
|
+
}
|
|
9
|
+
serverScripts[method] = (...args) => new Promise((resolve, reject) => {
|
|
10
|
+
google.script.run.withSuccessHandler(resolve).withFailureHandler(reject)[method](...args);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return serverScripts;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { ServerScripts };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ciderjs/gasnuki",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "0.1.5",
|
|
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",
|
|
7
7
|
"bin": {
|
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"import": "./dist/index.mjs",
|
|
14
14
|
"require": "./dist/index.cjs"
|
|
15
|
+
},
|
|
16
|
+
"./promise": {
|
|
17
|
+
"types": "./dist/promise.d.ts",
|
|
18
|
+
"import": "./dist/promise.mjs",
|
|
19
|
+
"require": "./dist/promise.cjs"
|
|
15
20
|
}
|
|
16
21
|
},
|
|
17
22
|
"scripts": {
|