@gasboost/fake-core 0.1.1 → 0.1.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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +169 -0
  3. package/package.json +1 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 gasboost
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,169 @@
1
+ # @gasboost/fake-core
2
+
3
+ Google Apps Script の組み込み API に対応する in-memory fake implementation を提供します。
4
+
5
+ Node.js 固有 API には依存せず、GAS API に依存するコードをテスト可能にするための基礎実装を担当します。
6
+
7
+ ## インストール
8
+
9
+ ```bash
10
+ pnpm add -D @gasboost/fake-core
11
+ ```
12
+
13
+ npm:
14
+
15
+ ```bash
16
+ npm install -D @gasboost/fake-core
17
+ ```
18
+
19
+ TypeScript で GAS の型を利用する場合は、必要に応じて型定義も追加してください。
20
+
21
+ ```bash
22
+ pnpm add -D @types/google-apps-script
23
+ ```
24
+
25
+ ## Public API
26
+
27
+ 現在の package entry point からは以下を公開しています。
28
+
29
+ ### Blob
30
+
31
+ - `InMemoryBlob`
32
+
33
+ `GoogleAppsScript.Base.Blob` を実装する in-memory Blob です。
34
+
35
+ ```ts
36
+ import { InMemoryBlob } from "@gasboost/fake-core";
37
+
38
+ const blob = new InMemoryBlob("hello", "text/plain", "hello.txt");
39
+
40
+ blob.getDataAsString();
41
+ blob.getBytes();
42
+ blob.getName();
43
+ ```
44
+
45
+ ### Cache
46
+
47
+ - `InMemoryCache`
48
+ - `InMemoryCacheService`
49
+
50
+ `GoogleAppsScript.Cache.Cache` と `CacheService` に対応する in-memory 実装です。
51
+
52
+ ```ts
53
+ import { InMemoryCacheService } from "@gasboost/fake-core";
54
+
55
+ const CacheService = new InMemoryCacheService();
56
+ const cache = CacheService.getScriptCache();
57
+
58
+ cache.put("key", "value");
59
+
60
+ console.log(cache.get("key"));
61
+ ```
62
+
63
+ `InMemoryCache` は expiration、key length、value size、保存件数など、現在実装されている GAS Cache の制約も再現します。
64
+
65
+ ### Properties Service
66
+
67
+ - `InMemoryProperties`
68
+ - `InMemoryPropertiesService`
69
+
70
+ `PropertiesService` の Document / User / Script Properties に対応する in-memory 実装です。
71
+
72
+ ```ts
73
+ import { InMemoryPropertiesService } from "@gasboost/fake-core";
74
+
75
+ const PropertiesService = new InMemoryPropertiesService();
76
+ const properties = PropertiesService.getScriptProperties();
77
+
78
+ properties.setProperty("key", "value");
79
+
80
+ console.log(properties.getProperty("key"));
81
+ ```
82
+
83
+ ### Session
84
+
85
+ - `InMemoryContext`
86
+ - `InMemorySession`
87
+ - `SecurityPolicy`
88
+ - `OAuthScope`
89
+
90
+ GAS の Session を、実行コンテキストと OAuth Scope を明示して再現するための実装です。
91
+
92
+ ```ts
93
+ import {
94
+ InMemoryContext,
95
+ InMemorySession,
96
+ OAuthScope,
97
+ SecurityPolicy,
98
+ } from "@gasboost/fake-core";
99
+
100
+ const context = new InMemoryContext(
101
+ "owner@example.com",
102
+ "user@example.com",
103
+ {
104
+ type: "WEB_APP",
105
+ executeAs: "USER",
106
+ },
107
+ new SecurityPolicy([OAuthScope.USERINFO_EMAIL]),
108
+ "ja",
109
+ "Asia/Tokyo",
110
+ );
111
+
112
+ const Session = new InMemorySession(context);
113
+
114
+ Session.getActiveUser();
115
+ Session.getEffectiveUser();
116
+ Session.getActiveUserLocale();
117
+ Session.getScriptTimeZone();
118
+ ```
119
+
120
+ 現在の `InMemoryContext` は以下の実行形態を扱います。
121
+
122
+ - Web App
123
+ - Trigger
124
+ - Custom Function
125
+
126
+ 実行形態、実行ユーザー、owner、domain、OAuth Scope に基づいて Session の user 情報を判定します。
127
+
128
+ ### Utilities support
129
+
130
+ package entry point から Utilities 実装を支える補助クラスも公開しています。
131
+
132
+ - `AppsScriptByte`
133
+ - `BinaryData`
134
+ - `DateFormatPattern`
135
+ - `Md2`
136
+ - `PartedDate`
137
+ - `StringCode`
138
+
139
+ これらは主に `@gasboost/fake-node` の `NodeUtilities` から利用されます。
140
+
141
+ 通常の利用では、Node.js 上の Utilities fake として `@gasboost/fake-node` を利用してください。
142
+
143
+ ## 責務
144
+
145
+ `@gasboost/fake-core` が担当するもの:
146
+
147
+ - GAS API の in-memory implementation
148
+ - Node.js 固有 API に依存しない fake
149
+ - Blob
150
+ - Cache / CacheService
151
+ - Properties / PropertiesService
152
+ - Session と実行コンテキスト
153
+ - Utilities 実装を支える共通処理
154
+
155
+ Node.js の crypto / zlib などに依存する `Utilities` の実装は `@gasboost/fake-node` が担当します。
156
+
157
+ ## 制約
158
+
159
+ Google Apps Script ランタイム全体を再現する package ではありません。
160
+
161
+ 現在実装されている class / method のみをサポート対象とします。
162
+
163
+ ## 関連パッケージ
164
+
165
+ - `@gasboost/fake-node` — Node.js 上で動作する Utilities implementation
166
+
167
+ ## License
168
+
169
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gasboost/fake-core",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "This package provides a fake implementation of Google Apps Script built-in services for testing purposes.",
5
5
  "license": "MIT",
6
6
  "author": "tiger-oshima",