@ciderjs/gasnuki 0.5.0 → 0.5.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.
package/README.ja.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @ciderjs/gasnuki
2
2
 
3
3
  [![README-en](https://img.shields.io/badge/English-blue?logo=ReadMe)](./README.md)
4
- [![Test Coverage](https://img.shields.io/badge/test%20coverage-93.03%25-brightgreen)](https://github.com/luthpg/gasnuki)
4
+ [![Test Coverage](https://img.shields.io/badge/test%20coverage-92.76%25-brightgreen)](https://github.com/luthpg/gasnuki)
5
5
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
6
  [![npm version](https://img.shields.io/npm/v/@ciderjs/gasnuki.svg)](https://www.npmjs.com/package/@ciderjs/gasnuki)
7
7
  ![NPM Downloads](https://img.shields.io/npm/dw/@ciderjs/gasnuki)
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @ciderjs/gasnuki
2
2
 
3
3
  [![README-ja](https://img.shields.io/badge/日本語-blue?logo=ReadMe)](./README.ja.md)
4
- [![Test Coverage](https://img.shields.io/badge/test%20coverage-93.03%25-brightgreen)](https://github.com/luthpg/gasnuki)
4
+ [![Test Coverage](https://img.shields.io/badge/test%20coverage-92.76%25-brightgreen)](https://github.com/luthpg/gasnuki)
5
5
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
6
  [![npm version](https://img.shields.io/npm/v/@ciderjs/gasnuki.svg)](https://www.npmjs.com/package/@ciderjs/gasnuki)
7
7
  ![NPM Downloads](https://img.shields.io/npm/dw/@ciderjs/gasnuki)
package/dist/cli.cjs CHANGED
@@ -26,7 +26,7 @@ function _interopNamespaceCompat(e) {
26
26
 
27
27
  const path__namespace = /*#__PURE__*/_interopNamespaceCompat(path);
28
28
 
29
- const version = "0.5.0";
29
+ const version = "0.5.1";
30
30
 
31
31
  const parseArgs = async (command) => {
32
32
  const cliOpts = command.opts();
package/dist/cli.mjs CHANGED
@@ -10,7 +10,7 @@ import 'node:fs';
10
10
  import 'ts-morph';
11
11
  import 'jiti';
12
12
 
13
- const version = "0.5.0";
13
+ const version = "0.5.1";
14
14
 
15
15
  const parseArgs = async (command) => {
16
16
  const cliOpts = command.opts();
package/dist/promise.cjs CHANGED
@@ -7,7 +7,24 @@ function getPromisedServerScripts(options = {}) {
7
7
  return new Proxy(mockupFunctions, {
8
8
  get(target, method) {
9
9
  if (!("google" in globalThis) || !google?.script?.run) {
10
- return target[method];
10
+ const mockFunc = target[method];
11
+ if (!mockFunc) {
12
+ return void 0;
13
+ }
14
+ if (!parseJson) {
15
+ return mockFunc;
16
+ }
17
+ return async (...args) => {
18
+ const res = await mockFunc(...args);
19
+ if (typeof res === "string") {
20
+ try {
21
+ return json.deserialize(res);
22
+ } catch {
23
+ return res;
24
+ }
25
+ }
26
+ return res;
27
+ };
11
28
  }
12
29
  if (!(method in google.script.run)) {
13
30
  throw Error(`Method ${method} not found in AppsScript.`);
@@ -10,7 +10,7 @@ type PromisedWithJson<T> = {
10
10
  type PartialScriptType<T> = Partial<Promised<T>>;
11
11
  type PartialScriptTypeWithJson<T> = Partial<PromisedWithJson<T>>;
12
12
  type GetPromisedServerScriptsOptions<T, IsJson extends boolean = boolean> = {
13
- mockupFunctions?: IsJson extends true ? PartialScriptTypeWithJson<T> : PartialScriptType<T>;
13
+ mockupFunctions?: PartialScriptType<T>;
14
14
  parseJson?: IsJson;
15
15
  };
16
16
  declare function getPromisedServerScripts<T extends Record<string, (...args: any[]) => any> = Omit<typeof google.script.run, 'withSuccessHandler' | 'withFailureHandler' | 'withUserObject'>>(options: GetPromisedServerScriptsOptions<T, true>): PromisedWithJson<T>;
@@ -10,7 +10,7 @@ type PromisedWithJson<T> = {
10
10
  type PartialScriptType<T> = Partial<Promised<T>>;
11
11
  type PartialScriptTypeWithJson<T> = Partial<PromisedWithJson<T>>;
12
12
  type GetPromisedServerScriptsOptions<T, IsJson extends boolean = boolean> = {
13
- mockupFunctions?: IsJson extends true ? PartialScriptTypeWithJson<T> : PartialScriptType<T>;
13
+ mockupFunctions?: PartialScriptType<T>;
14
14
  parseJson?: IsJson;
15
15
  };
16
16
  declare function getPromisedServerScripts<T extends Record<string, (...args: any[]) => any> = Omit<typeof google.script.run, 'withSuccessHandler' | 'withFailureHandler' | 'withUserObject'>>(options: GetPromisedServerScriptsOptions<T, true>): PromisedWithJson<T>;
package/dist/promise.d.ts CHANGED
@@ -10,7 +10,7 @@ type PromisedWithJson<T> = {
10
10
  type PartialScriptType<T> = Partial<Promised<T>>;
11
11
  type PartialScriptTypeWithJson<T> = Partial<PromisedWithJson<T>>;
12
12
  type GetPromisedServerScriptsOptions<T, IsJson extends boolean = boolean> = {
13
- mockupFunctions?: IsJson extends true ? PartialScriptTypeWithJson<T> : PartialScriptType<T>;
13
+ mockupFunctions?: PartialScriptType<T>;
14
14
  parseJson?: IsJson;
15
15
  };
16
16
  declare function getPromisedServerScripts<T extends Record<string, (...args: any[]) => any> = Omit<typeof google.script.run, 'withSuccessHandler' | 'withFailureHandler' | 'withUserObject'>>(options: GetPromisedServerScriptsOptions<T, true>): PromisedWithJson<T>;
package/dist/promise.mjs CHANGED
@@ -5,7 +5,24 @@ function getPromisedServerScripts(options = {}) {
5
5
  return new Proxy(mockupFunctions, {
6
6
  get(target, method) {
7
7
  if (!("google" in globalThis) || !google?.script?.run) {
8
- return target[method];
8
+ const mockFunc = target[method];
9
+ if (!mockFunc) {
10
+ return void 0;
11
+ }
12
+ if (!parseJson) {
13
+ return mockFunc;
14
+ }
15
+ return async (...args) => {
16
+ const res = await mockFunc(...args);
17
+ if (typeof res === "string") {
18
+ try {
19
+ return deserialize(res);
20
+ } catch {
21
+ return res;
22
+ }
23
+ }
24
+ return res;
25
+ };
9
26
  }
10
27
  if (!(method in google.script.run)) {
11
28
  throw Error(`Method ${method} not found in AppsScript.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ciderjs/gasnuki",
3
- "version": "0.5.0",
3
+ "version": "0.5.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",