@niscorp/solid 0.1.0
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/DESIGN.md +320 -0
- package/LICENSE +202 -0
- package/README.md +184 -0
- package/dist/index.cjs +1269 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +34 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +1267 -0
- package/dist/index.js.map +1 -0
- package/package.json +69 -0
package/DESIGN.md
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
# @niscorp/solid — Design
|
|
2
|
+
|
|
3
|
+
How the library works, what decisions were made, and why.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## The problem
|
|
8
|
+
|
|
9
|
+
LLMs that produce structured output stream JSON token by token. Before the last token arrives, the JSON is incomplete — you can't `JSON.parse` it. But you want to show fields to the user as they appear, react to subtrees as they finalize, and never expose an invalid state.
|
|
10
|
+
|
|
11
|
+
The naive solution is to repair the partial JSON (close brackets, trim dangling tokens) and re-parse the entire buffer on every chunk. This works but scales quadratically — every write re-scans everything that came before it.
|
|
12
|
+
|
|
13
|
+
Solid takes a different approach.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Core idea
|
|
18
|
+
|
|
19
|
+
The streamed JSON is not the state. The state is a valid object that exists from the start.
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
const stream = createStream({ schema, initial });
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`initial` is validated against the Zod schema at construction. Every `current()` call returns a valid object — before, during, and after streaming. The incoming JSON progressively overwrites fields in this object as they're parsed.
|
|
26
|
+
|
|
27
|
+
This means consumers can render and act on the state immediately. There is no "waiting for valid JSON" phase.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Architecture
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
write(chunk)
|
|
35
|
+
│
|
|
36
|
+
▼
|
|
37
|
+
┌─────────────────────────┐
|
|
38
|
+
│ Incremental parser │ O(chunk) — processes only new characters
|
|
39
|
+
│ ├─ Scanner state │ tracks strings, escapes, containers, paths
|
|
40
|
+
│ ├─ Value-open hook ──────┼──→ Validator (kind check → accept | skip)
|
|
41
|
+
│ ├─ Skip-mode │ consumes rejected subtrees without writing
|
|
42
|
+
│ ├─ Value extraction │ writes accepted values into mutable root
|
|
43
|
+
│ ├─ Dirty tracking │ records which paths were modified
|
|
44
|
+
│ └─ Event emission │ structural events for finalization
|
|
45
|
+
└────────────┬────────────┘
|
|
46
|
+
│
|
|
47
|
+
┌───────┴───────┐
|
|
48
|
+
│ │
|
|
49
|
+
▼ ▼
|
|
50
|
+
┌──────────┐ ┌──────────────────┐
|
|
51
|
+
│ Snapshot │ │ Finalization │
|
|
52
|
+
│ engine │ │ tracker │
|
|
53
|
+
│ │ │ │
|
|
54
|
+
│ Structural│ │ Marks paths as │
|
|
55
|
+
│ sharing │ │ final based on │
|
|
56
|
+
│ from prev │ │ parser events │
|
|
57
|
+
│ snapshot │ │ │
|
|
58
|
+
└─────┬─────┘ └───────┬─────────┘
|
|
59
|
+
│ │
|
|
60
|
+
▼ ▼
|
|
61
|
+
┌──────────────────────────────┐
|
|
62
|
+
│ Validator (finalize phase) │ opt-in: safeParse per field at close
|
|
63
|
+
│ └─ reads keys from tracker │
|
|
64
|
+
└──────────────┬───────────────┘
|
|
65
|
+
│
|
|
66
|
+
▼
|
|
67
|
+
┌──────────────────────────────┐
|
|
68
|
+
│ Stream (root + selections) │
|
|
69
|
+
│ ├─ on() — reference === │
|
|
70
|
+
│ ├─ onFinal() │
|
|
71
|
+
│ ├─ onError() — path-scoped │
|
|
72
|
+
│ ├─ select() — cached │
|
|
73
|
+
│ └─ destroy() │
|
|
74
|
+
└──────────────────────────────┘
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Files
|
|
78
|
+
|
|
79
|
+
| File | Responsibility |
|
|
80
|
+
|------|----------------|
|
|
81
|
+
| `incremental-parser.ts` | Scanner, value extraction, dirty tracking, structural sharing snapshots, value-open hook, skip-mode |
|
|
82
|
+
| `finalization-tracker.ts` | Determines when paths become final based on parser events |
|
|
83
|
+
| `schema-walker.ts` | Given a Zod schema and path, returns sub-schema + accepted JSON kinds |
|
|
84
|
+
| `validator.ts` | Enforces the invariant: kind checks at value-open, sub-schema safeParse at finalize |
|
|
85
|
+
| `create-stream.ts` | Root stream factory, listener management, write pipeline, error/failed-state plumbing |
|
|
86
|
+
| `selected-stream.ts` | Projected subtree streams with independent subscriptions, path-scoped onError |
|
|
87
|
+
| `types.ts` | Public and internal types, FinalState factory |
|
|
88
|
+
| `path.ts` | Path splitting, traversal, projection |
|
|
89
|
+
| `derive-defaults.ts` | Derives valid base objects from Zod schema defaults |
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Key decisions
|
|
94
|
+
|
|
95
|
+
### 1. Incremental parsing, not repair+parse
|
|
96
|
+
|
|
97
|
+
**Decision:** Build a custom incremental JSON parser instead of repairing partial JSON and calling `JSON.parse`.
|
|
98
|
+
|
|
99
|
+
**Why:** The repair+parse approach re-scans the entire accumulated buffer on every `write()`. Over N total characters in ~N/100 chunks, total work is O(N²). For a 20 KB response that's measurably slow (~38ms). The incremental parser maintains scanner state between calls and processes only new characters — O(N) total.
|
|
100
|
+
|
|
101
|
+
**Trade-off:** We own the parser. If a JSON edge case breaks, it's our bug. We mitigate this with thorough tests (192 unit/integration tests + e2e streaming tests).
|
|
102
|
+
|
|
103
|
+
**Result:** 44x faster for character-by-character streaming of a 10 KB payload.
|
|
104
|
+
|
|
105
|
+
### 2. Structural sharing, not deep cloning
|
|
106
|
+
|
|
107
|
+
**Decision:** Produce immutable snapshots using copy-on-write structural sharing instead of `structuredClone`.
|
|
108
|
+
|
|
109
|
+
**Why:** The parser mutates an internal object. Consumers need immutable values (so stored references don't change under them). `structuredClone` copies the entire object tree — O(object_size) per write. Structural sharing only creates new objects along dirty paths; everything else keeps the same reference from the previous snapshot.
|
|
110
|
+
|
|
111
|
+
**How it works:**
|
|
112
|
+
- The parser tracks which paths were modified during a `write()` via a `dirtyParents` map (parent path → set of changed child keys).
|
|
113
|
+
- The `snapshot(previous)` method walks the tree. At each node, if no children are dirty, it returns the `previous` reference directly. If children are dirty, it creates a new object with the dirty children replaced and clean children shared.
|
|
114
|
+
- After the snapshot, the dirty map is cleared.
|
|
115
|
+
|
|
116
|
+
**Result:** O(dirty_paths × depth) per snapshot instead of O(object_size). For a write that changes one string field at depth 3, that's ~3 object spreads instead of cloning a 20-field object tree.
|
|
117
|
+
|
|
118
|
+
### 3. Reference equality, not deep comparison
|
|
119
|
+
|
|
120
|
+
**Decision:** Selected streams use `===` for change detection instead of `deepEqual`.
|
|
121
|
+
|
|
122
|
+
**Why:** Structural sharing guarantees that unchanged subtrees keep the same object reference. If `snapshot.widget === previousSnapshot.widget`, the widget didn't change. This makes change detection O(1) instead of O(subtree_size).
|
|
123
|
+
|
|
124
|
+
**Consequence:** `select('widget').on(...)` only fires when the widget subtree actually changed. It does NOT fire when sibling fields (like `response`) change — even though the root object is new, the widget reference is shared.
|
|
125
|
+
|
|
126
|
+
### 4. Partial string visibility
|
|
127
|
+
|
|
128
|
+
**Decision:** String values are visible character by character as they stream in, not only when the closing quote arrives.
|
|
129
|
+
|
|
130
|
+
**Why:** LLM responses often contain long text fields. Waiting for the closing quote means the user sees nothing until the entire field is complete. By setting the partial string value on every character, `on(...)` subscribers see the text grow in real time.
|
|
131
|
+
|
|
132
|
+
**How:** The parser calls `setValue(valueBuffer)` on every non-escape character while inside a string. The dirty tracking and snapshot machinery handle the rest.
|
|
133
|
+
|
|
134
|
+
### 5. Skip-if-unchanged for setValue
|
|
135
|
+
|
|
136
|
+
**Decision:** The parser checks `value !== existing` before marking a path dirty.
|
|
137
|
+
|
|
138
|
+
**Why:** Without this, writing `{"type":""}` when the base already has `type: ""` would create a new snapshot (dirty flag set), which would trigger notifications and create new object references — even though nothing actually changed. The `!==` check prevents this.
|
|
139
|
+
|
|
140
|
+
**For primitives:** `=== ` catches identity. `"card" !== ""` is true (changed). `"" !== ""` is false (skip).
|
|
141
|
+
|
|
142
|
+
**For containers:** New objects/arrays created by `enterContainer` always have a different reference, so `!==` always holds. Correct — a new container IS a change.
|
|
143
|
+
|
|
144
|
+
### 6. Left-to-right finalization
|
|
145
|
+
|
|
146
|
+
**Decision:** Subtree finalization is based on parser position, not value completeness.
|
|
147
|
+
|
|
148
|
+
**Why:** JSON objects are ordered. When the parser sees key `"response"` at root depth, it knows `"widget"` can never receive more data — the producer has moved on. This is a structural guarantee, not a heuristic.
|
|
149
|
+
|
|
150
|
+
**Assumption:** Producers emit keys in a deliberate order. LLM structured output does this naturally — the model writes fields left to right. Consumers should place immediately useful fields first (UI/render → text → reasoning → metadata).
|
|
151
|
+
|
|
152
|
+
**Implementation:** The finalization tracker maintains a `keysPerContainer` map. When a new key enters, all previous sibling keys (and their descendants) are finalized. When a container closes, all its children are finalized.
|
|
153
|
+
|
|
154
|
+
### 7. Events decouple parsing from finalization
|
|
155
|
+
|
|
156
|
+
**Decision:** The parser emits `ParserEvent` objects that the finalization tracker consumes, rather than the tracker being embedded in the parser.
|
|
157
|
+
|
|
158
|
+
**Why:** Separation of concerns. The parser knows about JSON syntax. The tracker knows about path finalization semantics. Neither needs to know about the other's internals. Events are the interface.
|
|
159
|
+
|
|
160
|
+
**Event types:** `enterObject`, `leaveObject`, `enterArray`, `leaveArray`, `enterKey`, `enterIndex`, `valueComplete`.
|
|
161
|
+
|
|
162
|
+
### 8. Selected streams are projections, not copies
|
|
163
|
+
|
|
164
|
+
**Decision:** `select('widget')` returns a lightweight wrapper that projects from the root state, not an independent stream with its own parse buffer.
|
|
165
|
+
|
|
166
|
+
**Why:** All parsing happens once at root. Selected streams are just lenses into the root state. They subscribe to root change signals (value-free — no type casting needed), project their subtree via `getByPath`, and compare with the previous reference.
|
|
167
|
+
|
|
168
|
+
**Caching:** `select('widget')` always returns the same stream instance. The cache is a `Map<string, Stream>` on the root.
|
|
169
|
+
|
|
170
|
+
### 9. Factory functions, not classes
|
|
171
|
+
|
|
172
|
+
**Decision:** Follow the codebase style guide — factory functions returning explicit interfaces.
|
|
173
|
+
|
|
174
|
+
**Why:** Closures for private state, explicit return objects for public surface. No `this` binding issues. Testable, composable, tree-shakeable.
|
|
175
|
+
|
|
176
|
+
### 10. Element-level array merge
|
|
177
|
+
|
|
178
|
+
**Decision:** Array elements are merged by index, not replaced wholesale.
|
|
179
|
+
|
|
180
|
+
**Why:** With wholesale replacement, `select('items.0')` would see a "change" on every write that touches the array — because the array reference is new even if index 0 didn't change. Element-level merge means each index is tracked independently. The finalization tracker treats array indices like object keys.
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Performance characteristics
|
|
185
|
+
|
|
186
|
+
### Per-write cost
|
|
187
|
+
|
|
188
|
+
| Operation | Complexity |
|
|
189
|
+
|-----------|-----------|
|
|
190
|
+
| Parser scan | O(chunk_length) |
|
|
191
|
+
| Dirty tracking | O(depth) per value set |
|
|
192
|
+
| Snapshot | O(dirty_paths × depth) |
|
|
193
|
+
| Finalization check | O(events) |
|
|
194
|
+
| Selected stream notify | O(1) per selection (reference ===) |
|
|
195
|
+
|
|
196
|
+
Total per-write: **O(chunk_length + dirty_count × depth)**
|
|
197
|
+
|
|
198
|
+
### Scaling
|
|
199
|
+
|
|
200
|
+
| Payload | Chunks (50B) | Total time |
|
|
201
|
+
|---------|-------------|-----------|
|
|
202
|
+
| 1 KB | 21 | 0.4ms |
|
|
203
|
+
| 5 KB | 105 | 1.0ms |
|
|
204
|
+
| 10 KB | 210 | 3.2ms |
|
|
205
|
+
| 20 KB | 419 | 12ms |
|
|
206
|
+
|
|
207
|
+
Scaling ratio (20KB/1KB ms/KB): **1.4x** — effectively linear.
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## The always-valid invariant
|
|
212
|
+
|
|
213
|
+
Solid's central promise: whatever `current()` returns is structurally valid against the schema. Not "will be valid eventually" — valid right now, and after every write. This holds regardless of what the LLM sends.
|
|
214
|
+
|
|
215
|
+
### The problem it solves
|
|
216
|
+
|
|
217
|
+
Without validation during streaming, a hallucinated field quietly corrupts the tree. Schema says `count: number`, LLM emits `"count": "three"`, consumer does `x.count + 1` and gets `"three1"`. Schema says `items: T[]`, LLM emits `"items": "oops"`, consumer does `items.map(...)` and crashes. TypeScript said the type was a number, the object says it's a string, and nobody noticed.
|
|
218
|
+
|
|
219
|
+
Solid enforces the invariant at two phases:
|
|
220
|
+
|
|
221
|
+
### Phase 1 — value-open kind check (always on)
|
|
222
|
+
|
|
223
|
+
The moment the parser sees the first character of a value (`{`, `[`, `"`, digit, `t`/`f`/`n`), it knows the value's JSON kind. It calls a hook into the validator with `(path, kind)`. The validator walks the schema tree from the root to that path via `schema-walker.ts` and returns `accept` or `skip`.
|
|
224
|
+
|
|
225
|
+
On `skip`, the parser enters **skip-mode**: it consumes characters without writing values, without emitting events, without marking anything dirty. Skip-mode is bounded by matched quotes (strings, with escape awareness), matched braces/brackets (objects/arrays with depth counting), or literal terminators. Once the value closes, normal parsing resumes with the sibling or container close.
|
|
226
|
+
|
|
227
|
+
This is O(1) per value — one path lookup, one `Set.has`. No `safeParse`, no allocation, no hot-path cost.
|
|
228
|
+
|
|
229
|
+
### Phase 2 — finalize constraints (opt-in)
|
|
230
|
+
|
|
231
|
+
Kind checks catch type-shape mismatches. They don't catch `.min(5)` on a string, `.int()` on a number, `.email()`, `.regex(...)`, or `.refine(...)`. Those require the complete value. Running them on a partial string would produce false positives — a 3-character string in flight isn't yet the 20-character string it will be when the closing quote arrives.
|
|
232
|
+
|
|
233
|
+
With `constraints: 'finalize'`, the validator runs `subSchema.safeParse(currentValue)` exactly once per field, at the moment that field finalizes (the tracker-reported structural close). Partial strings never trip constraints they're about to satisfy, because the check only fires after the final character has been written.
|
|
234
|
+
|
|
235
|
+
### Modes
|
|
236
|
+
|
|
237
|
+
Three modes govern what happens on a violation:
|
|
238
|
+
|
|
239
|
+
- **`trust`** — no validation. Today's pre-invariant behavior. Included as a debug escape hatch; discouraged in production.
|
|
240
|
+
- **`recover`** (default) — the bad value is skipped, the prior valid value stays in place, an error is emitted via `onError`, and the stream continues. One hallucinated field doesn't tank the rest of the response.
|
|
241
|
+
- **`strict`** — the bad value is skipped, an error is emitted once, the stream enters a terminal failed state. `current()` freezes at the last valid snapshot, further writes are no-ops, `final()` rejects. For when rendering wrong is worse than rendering nothing.
|
|
242
|
+
|
|
243
|
+
### Consequences
|
|
244
|
+
|
|
245
|
+
- `current()` is always shape-valid (in `recover` and `strict`).
|
|
246
|
+
- `current()` is *not* always constraint-valid mid-stream — that's what `select(path).final()` and `constraints: 'finalize'` are for.
|
|
247
|
+
- No throwing from `write()`. All error surfaces go through `onError` + `final()` rejection. Signal adapters and other producer loops can write without try/catch.
|
|
248
|
+
- Selected streams see only errors at-or-below their path. `select('widget').onError(...)` ignores errors on sibling fields.
|
|
249
|
+
|
|
250
|
+
### Sub-schema walking
|
|
251
|
+
|
|
252
|
+
`schema-walker.ts` walks the top-level Zod schema along a path:
|
|
253
|
+
|
|
254
|
+
- `ZodObject` → `shape[key]`
|
|
255
|
+
- `ZodArray` → `element`
|
|
256
|
+
- `ZodTuple` → `items[idx]` or `rest`
|
|
257
|
+
- `ZodRecord` → `valueType`
|
|
258
|
+
- `ZodUnion` → first variant that accepts the segment
|
|
259
|
+
- `ZodOptional` / `ZodNullable` / `ZodDefault` → unwrap and recurse
|
|
260
|
+
- `ZodLiteral`, `ZodEnum`, `ZodString/Number/Boolean/Null` → leaf kinds
|
|
261
|
+
- Discriminated unions → object kind; full narrowing deferred to finalize
|
|
262
|
+
- `ZodLazy` / `ZodIntersection` / `ZodPipeline` / `ZodAny` / `ZodUnknown` → accept-any (kind check skipped; finalize still runs if enabled)
|
|
263
|
+
|
|
264
|
+
The walker caches nothing; the lookup is O(depth) per value. For typical schemas (depth 3–5), that's a few property accesses per write.
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## What this library is not
|
|
269
|
+
|
|
270
|
+
- **Not a generic JSON parser.** It's purpose-built for schema-backed LLM streaming.
|
|
271
|
+
- **Not a diff engine.** It doesn't compute patches or deltas. It tracks dirty paths for structural sharing.
|
|
272
|
+
- **Not a recovery tool for malformed JSON.** If the LLM sends syntactically broken JSON (unmatched braces, bad escapes), the parser ignores the unparseable tokens and keeps the last valid state. It doesn't guess or repair JSON — it only rejects schema mismatches at value-open.
|
|
273
|
+
- **Not a coercion engine.** If you want `z.coerce.number().parse("3")` behavior, put it in your schema. Solid doesn't transform values.
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Public API
|
|
278
|
+
|
|
279
|
+
```ts
|
|
280
|
+
type Stream<T> = {
|
|
281
|
+
write: (chunk: string) => void;
|
|
282
|
+
close: () => void;
|
|
283
|
+
destroy: () => void;
|
|
284
|
+
current: () => T;
|
|
285
|
+
final: () => Promise<T>;
|
|
286
|
+
on: (listener: (value: T) => void) => () => void;
|
|
287
|
+
onFinal: (listener: (value: T) => void) => () => void;
|
|
288
|
+
onError: (listener: (error: StreamError) => void) => () => void;
|
|
289
|
+
select: <P = unknown>(path: string) => Stream<P>;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
type StreamError = {
|
|
293
|
+
path: string;
|
|
294
|
+
expected: string;
|
|
295
|
+
received: string;
|
|
296
|
+
phase: 'value-open' | 'finalize';
|
|
297
|
+
message: string;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
const createStream: <T>(options: {
|
|
301
|
+
schema: z.ZodType<T>;
|
|
302
|
+
initial?: T;
|
|
303
|
+
mode?: 'trust' | 'recover' | 'strict'; // default: 'recover'
|
|
304
|
+
constraints?: 'kind' | 'finalize'; // default: 'kind'
|
|
305
|
+
}) => Stream<T>;
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
Nine methods. That's the whole product.
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## Known limitations
|
|
313
|
+
|
|
314
|
+
### Path separator
|
|
315
|
+
|
|
316
|
+
All path operations use `.` as the separator. Keys containing literal dots (e.g. `"foo.bar"`) will be split and misinterpreted. In practice this never arises — LLM structured output schemas use simple identifier keys — but there is no escaping mechanism if it does.
|
|
317
|
+
|
|
318
|
+
### `select('')` observes all errors
|
|
319
|
+
|
|
320
|
+
`select('')` returns a stream that projects the entire root. Its `onError` listener fires for errors at *every* path, since all paths are at-or-below the root. This is consistent with the semantics (root selection = whole tree) but may surprise consumers who expect only root-level errors. Use `select('specific.path')` for scoped error observation.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|