@htlkg/data 0.0.3 → 0.0.11
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htlkg/data",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -38,16 +38,19 @@
|
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@aws-amplify/api": "^6.0.0",
|
|
41
|
-
"vue": "^3.5.22",
|
|
42
41
|
"zod": "^3.22.0",
|
|
43
|
-
"@htlkg/core": "0.0.
|
|
42
|
+
"@htlkg/core": "0.0.10"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"vue": "^3.5.0"
|
|
44
46
|
},
|
|
45
47
|
"publishConfig": {
|
|
46
|
-
"access": "
|
|
48
|
+
"access": "public"
|
|
47
49
|
},
|
|
48
50
|
"devDependencies": {
|
|
49
51
|
"astro": "^5.14.7",
|
|
50
52
|
"aws-amplify": "^6.15.7",
|
|
53
|
+
"vue": "^3.5.22",
|
|
51
54
|
"tsup": "^8.0.0",
|
|
52
55
|
"typescript": "^5.9.2",
|
|
53
56
|
"vitest": "^3.2.4"
|
|
@@ -56,6 +59,9 @@
|
|
|
56
59
|
"build": "tsup",
|
|
57
60
|
"dev": "tsup --watch",
|
|
58
61
|
"test": "vitest run",
|
|
59
|
-
"test:watch": "vitest"
|
|
62
|
+
"test:watch": "vitest",
|
|
63
|
+
"version:patch": "pnpm version patch --no-git-tag-version",
|
|
64
|
+
"version:minor": "pnpm version minor --no-git-tag-version",
|
|
65
|
+
"version:major": "pnpm version major --no-git-tag-version"
|
|
60
66
|
}
|
|
61
67
|
}
|
|
@@ -5,6 +5,12 @@ import type { ResourcesConfig } from 'aws-amplify';
|
|
|
5
5
|
// Mock dependencies
|
|
6
6
|
vi.mock('@htlkg/core/amplify-astro-adapter', () => ({
|
|
7
7
|
createRunWithAmplifyServerContext: vi.fn(() => vi.fn()),
|
|
8
|
+
createLogger: vi.fn(() => ({
|
|
9
|
+
debug: vi.fn(),
|
|
10
|
+
info: vi.fn(),
|
|
11
|
+
warn: vi.fn(),
|
|
12
|
+
error: vi.fn(),
|
|
13
|
+
})),
|
|
8
14
|
}));
|
|
9
15
|
|
|
10
16
|
vi.mock('aws-amplify/adapter-core/internals', () => ({
|
package/src/client/index.test.ts
CHANGED
|
@@ -36,7 +36,13 @@ vi.mock('aws-amplify/data', () => ({
|
|
|
36
36
|
|
|
37
37
|
// Mock @htlkg/core/amplify-astro-adapter
|
|
38
38
|
vi.mock('@htlkg/core/amplify-astro-adapter', () => ({
|
|
39
|
-
createRunWithAmplifyServerContext: vi.fn(() => vi.fn())
|
|
39
|
+
createRunWithAmplifyServerContext: vi.fn(() => vi.fn()),
|
|
40
|
+
createLogger: vi.fn(() => ({
|
|
41
|
+
debug: vi.fn(),
|
|
42
|
+
info: vi.fn(),
|
|
43
|
+
warn: vi.fn(),
|
|
44
|
+
error: vi.fn(),
|
|
45
|
+
})),
|
|
40
46
|
}));
|
|
41
47
|
|
|
42
48
|
// Mock aws-amplify/auth/server
|
|
@@ -103,113 +109,73 @@ describe('generateServerClient', () => {
|
|
|
103
109
|
vi.clearAllMocks();
|
|
104
110
|
});
|
|
105
111
|
|
|
106
|
-
describe('
|
|
107
|
-
it('should generate a server-side client
|
|
108
|
-
const client = generateServerClient(
|
|
109
|
-
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
+
describe('basic functionality', () => {
|
|
113
|
+
it('should generate a server-side client', () => {
|
|
114
|
+
const client = generateServerClient();
|
|
115
|
+
|
|
112
116
|
expect(client).toBeDefined();
|
|
113
117
|
expect(client.models).toBeDefined();
|
|
114
118
|
});
|
|
115
|
-
|
|
116
|
-
it('should
|
|
117
|
-
generateServerClient(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
expect(generateDataClient).
|
|
122
|
-
authMode: 'userPool'
|
|
123
|
-
});
|
|
119
|
+
|
|
120
|
+
it('should call generateDataClient without options', () => {
|
|
121
|
+
generateServerClient();
|
|
122
|
+
|
|
123
|
+
// generateServerClient calls generateDataClient without parameters
|
|
124
|
+
// authMode is specified per-operation, not at client creation
|
|
125
|
+
expect(generateDataClient).toHaveBeenCalled();
|
|
124
126
|
});
|
|
125
|
-
|
|
127
|
+
|
|
126
128
|
it('should not call Amplify.configure (should be done at app startup)', () => {
|
|
127
129
|
vi.clearAllMocks();
|
|
128
|
-
|
|
129
|
-
generateServerClient(
|
|
130
|
-
|
|
131
|
-
});
|
|
132
|
-
|
|
130
|
+
|
|
131
|
+
generateServerClient();
|
|
132
|
+
|
|
133
133
|
// generateServerClient should NOT call Amplify.configure
|
|
134
134
|
// It should be called once at app startup (e.g., in amplify-server.ts)
|
|
135
135
|
expect(Amplify.configure).not.toHaveBeenCalled();
|
|
136
136
|
});
|
|
137
|
-
|
|
137
|
+
|
|
138
138
|
it('should not call createRunWithAmplifyServerContext (should be done outside)', () => {
|
|
139
139
|
vi.clearAllMocks();
|
|
140
|
-
|
|
141
|
-
generateServerClient(
|
|
142
|
-
|
|
143
|
-
});
|
|
144
|
-
|
|
140
|
+
|
|
141
|
+
generateServerClient();
|
|
142
|
+
|
|
145
143
|
// generateServerClient should NOT call createRunWithAmplifyServerContext
|
|
146
144
|
// The caller should wrap the operation with runWithAmplifyServerContext
|
|
147
145
|
expect(createRunWithAmplifyServerContext).not.toHaveBeenCalled();
|
|
148
146
|
});
|
|
149
147
|
});
|
|
150
|
-
|
|
151
|
-
describe('with
|
|
152
|
-
it('should
|
|
148
|
+
|
|
149
|
+
describe('with options', () => {
|
|
150
|
+
it('should accept authMode option', () => {
|
|
153
151
|
const client = generateServerClient({
|
|
154
|
-
config: mockConfig,
|
|
155
152
|
authMode: 'apiKey'
|
|
156
153
|
});
|
|
157
|
-
|
|
154
|
+
|
|
158
155
|
expect(client).toBeDefined();
|
|
159
156
|
expect(client.models).toBeDefined();
|
|
160
157
|
});
|
|
161
|
-
|
|
162
|
-
it('should
|
|
163
|
-
generateServerClient({
|
|
164
|
-
config: mockConfig,
|
|
165
|
-
authMode: 'apiKey'
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
expect(generateDataClient).toHaveBeenCalledWith({
|
|
169
|
-
authMode: 'apiKey'
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
describe('configuration', () => {
|
|
175
|
-
it('should accept valid Amplify configuration', () => {
|
|
176
|
-
const client = generateServerClient({
|
|
177
|
-
config: mockConfig
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
expect(client).toBeDefined();
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it('should handle configuration with minimal auth setup', () => {
|
|
184
|
-
const minimalConfig = {
|
|
185
|
-
auth: {
|
|
186
|
-
user_pool_id: 'test-pool',
|
|
187
|
-
aws_region: 'us-east-1',
|
|
188
|
-
user_pool_client_id: 'test-client'
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
|
|
158
|
+
|
|
159
|
+
it('should accept userPool authMode option', () => {
|
|
192
160
|
const client = generateServerClient({
|
|
193
|
-
|
|
194
|
-
authMode: 'apiKey'
|
|
161
|
+
authMode: 'userPool'
|
|
195
162
|
});
|
|
196
|
-
|
|
163
|
+
|
|
197
164
|
expect(client).toBeDefined();
|
|
165
|
+
expect(client.models).toBeDefined();
|
|
198
166
|
});
|
|
199
167
|
});
|
|
200
168
|
|
|
201
169
|
describe('multiple instances', () => {
|
|
202
170
|
it('should allow creating multiple server clients', () => {
|
|
203
171
|
const client1 = generateServerClient({
|
|
204
|
-
config: mockConfig,
|
|
205
172
|
authMode: 'userPool'
|
|
206
173
|
});
|
|
207
|
-
|
|
174
|
+
|
|
208
175
|
const client2 = generateServerClient({
|
|
209
|
-
config: mockConfig,
|
|
210
176
|
authMode: 'apiKey'
|
|
211
177
|
});
|
|
212
|
-
|
|
178
|
+
|
|
213
179
|
expect(client1).toBeDefined();
|
|
214
180
|
expect(client2).toBeDefined();
|
|
215
181
|
});
|