@ciderjs/gasnuki 0.2.0 → 0.2.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.
@@ -1,4 +1,4 @@
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];
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.Yj84yCWz.cjs');
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.0";
27
+ const version = "0.2.1";
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.C-MvXA42.mjs';
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.0";
11
+ const version = "0.2.1";
12
12
 
13
13
  const parseArgs = async (command) => {
14
14
  const cliOpts = command.opts();
package/dist/index.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  require('node:path');
4
4
  require('chokidar');
5
5
  require('consola');
6
- const index = require('./shared/gasnuki.Yj84yCWz.cjs');
6
+ const index = require('./shared/gasnuki.D0Jm2dZh.cjs');
7
7
  require('node:fs');
8
8
  require('ts-morph');
9
9
  require('jiti');
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.C-MvXA42.mjs';
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 ServerScripts = () => {
4
- const serverScripts = {};
3
+ const getPromisedServerScripts = (mockupFunctions = {}) => {
4
+ const serverScripts = {
5
+ ...mockupFunctions
6
+ };
7
+ if (!("google" in globalThis)) {
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.ServerScripts = ServerScripts;
23
+ exports.getPromisedServerScripts = getPromisedServerScripts;
@@ -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
- declare const ServerScripts: <T extends Record<string, (...args: any[]) => any> = Omit<Omit<Omit<typeof google.script.run, "withSuccessHandler">, "withFailureHandler">, "withUserObject">>() => Promised<T>;
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 { ServerScripts };
7
+ export { getPromisedServerScripts };
8
+ export type { PartialScriptType, Promised };
@@ -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
- declare const ServerScripts: <T extends Record<string, (...args: any[]) => any> = Omit<Omit<Omit<typeof google.script.run, "withSuccessHandler">, "withFailureHandler">, "withUserObject">>() => Promised<T>;
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 { ServerScripts };
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
- declare const ServerScripts: <T extends Record<string, (...args: any[]) => any> = Omit<Omit<Omit<typeof google.script.run, "withSuccessHandler">, "withFailureHandler">, "withUserObject">>() => Promised<T>;
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 { ServerScripts };
7
+ export { getPromisedServerScripts };
8
+ export type { PartialScriptType, Promised };
package/dist/promise.mjs CHANGED
@@ -1,5 +1,10 @@
1
- const ServerScripts = () => {
2
- const serverScripts = {};
1
+ const getPromisedServerScripts = (mockupFunctions = {}) => {
2
+ const serverScripts = {
3
+ ...mockupFunctions
4
+ };
5
+ if (!("google" in globalThis)) {
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 { ServerScripts };
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.0",
3
+ "version": "0.2.1",
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",
@@ -21,12 +21,14 @@
21
21
  },
22
22
  "scripts": {
23
23
  "prebuild": "jiti bin/generate.ts",
24
- "dev": "pnpm prebuild && jiti src/cli.ts -p playground/react",
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 check && 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",