Skip to content

Commit 0e343c8

Browse files
authored
feat(firestore): replace Type enum with raw string. (#9725)
1 parent 44c234c commit 0e343c8

10 files changed

Lines changed: 56 additions & 104 deletions

File tree

.changeset/thin-seas-accept.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'firebase': minor
3+
'@firebase/firestore': minor
4+
---
5+
6+
**Beta API Breaking Change**: Change `Type` string union to be a raw string.

common/api-review/firestore-lite-pipelines.api.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ export abstract class Expression {
653653
/* Excluded from this release type: _readUserData */
654654
isError(): BooleanExpression;
655655
/* Excluded from this release type: _readUserData */
656-
isType(type: Type): BooleanExpression;
656+
isType(type: string): BooleanExpression;
657657
/* Excluded from this release type: _readUserData */
658658
join(delimiterExpression: Expression): Expression;
659659
/* Excluded from this release type: _readUserData */
@@ -959,10 +959,10 @@ export function isAbsent(field: string): BooleanExpression;
959959
export function isError(value: Expression): BooleanExpression;
960960

961961
// @public
962-
export function isType(fieldName: string, type: Type): BooleanExpression;
962+
export function isType(fieldName: string, type: string): BooleanExpression;
963963

964964
// @public
965-
export function isType(expression: Expression, type: Type): BooleanExpression;
965+
export function isType(expression: Expression, type: string): BooleanExpression;
966966

967967
// @public
968968
export function join(arrayFieldName: string, delimiter: string): Expression;
@@ -1675,9 +1675,6 @@ export function trunc(fieldName: string, decimalPlaces: number | Expression): Fu
16751675
// @public
16761676
export function trunc(expression: Expression, decimalPlaces: number | Expression): FunctionExpression;
16771677

1678-
// @public
1679-
export type Type = 'null' | 'array' | 'boolean' | 'bytes' | 'timestamp' | 'geo_point' | 'number' | 'int32' | 'int64' | 'float64' | 'decimal128' | 'map' | 'reference' | 'string' | 'vector' | 'max_key' | 'min_key' | 'object_id' | 'regex' | 'request_timestamp';
1680-
16811678
// @public
16821679
export function type(fieldName: string): FunctionExpression;
16831680

common/api-review/firestore-pipelines.api.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ export abstract class Expression {
656656
/* Excluded from this release type: _readUserData */
657657
isError(): BooleanExpression;
658658
/* Excluded from this release type: _readUserData */
659-
isType(type: Type): BooleanExpression;
659+
isType(type: string): BooleanExpression;
660660
/* Excluded from this release type: _readUserData */
661661
join(delimiterExpression: Expression): Expression;
662662
/* Excluded from this release type: _readUserData */
@@ -962,10 +962,10 @@ export function isAbsent(field: string): BooleanExpression;
962962
export function isError(value: Expression): BooleanExpression;
963963

964964
// @public
965-
export function isType(fieldName: string, type: Type): BooleanExpression;
965+
export function isType(fieldName: string, type: string): BooleanExpression;
966966

967967
// @public
968-
export function isType(expression: Expression, type: Type): BooleanExpression;
968+
export function isType(expression: Expression, type: string): BooleanExpression;
969969

970970
// @public
971971
export function join(arrayFieldName: string, delimiter: string): Expression;
@@ -1703,9 +1703,6 @@ export function trunc(fieldName: string, decimalPlaces: number | Expression): Fu
17031703
// @public
17041704
export function trunc(expression: Expression, decimalPlaces: number | Expression): FunctionExpression;
17051705

1706-
// @public
1707-
export type Type = 'null' | 'array' | 'boolean' | 'bytes' | 'timestamp' | 'geo_point' | 'number' | 'int32' | 'int64' | 'float64' | 'decimal128' | 'map' | 'reference' | 'string' | 'vector' | 'max_key' | 'min_key' | 'object_id' | 'regex' | 'request_timestamp';
1708-
17091706
// @public
17101707
export function type(fieldName: string): FunctionExpression;
17111708

docs-devsite/firestore_lite_pipelines.expression.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2499,19 +2499,19 @@ field("title").arrayContains(1).isError();
24992499
25002500
Creates an expression that checks if the result of this expression is of the given type.
25012501
2502-
Null or undefined fields evaluate to skip/error. Use `ifAbsent()` / `isAbsent()` to evaluate missing data.
2502+
Null or undefined fields evaluate to skip/error. Use `ifAbsent()` / `isAbsent()` to evaluate missing data. Supported values for `type` are: `'null'`<!-- -->, `'array'`<!-- -->, `'boolean'`<!-- -->, `'bytes'`<!-- -->, `'timestamp'`<!-- -->, `'geo_point'`<!-- -->, `'number'`<!-- -->, `'int32'`<!-- -->, `'int64'`<!-- -->, `'float64'`<!-- -->, `'decimal128'`<!-- -->, `'map'`<!-- -->, `'reference'`<!-- -->, `'string'`<!-- -->, `'vector'`<!-- -->, `'max_key'`<!-- -->, `'min_key'`<!-- -->, `'object_id'`<!-- -->, `'regex'`<!-- -->, `'request_timestamp'`<!-- -->.
25032503
25042504
<b>Signature:</b>
25052505
25062506
```typescript
2507-
isType(type: Type): BooleanExpression;
2507+
isType(type: string): BooleanExpression;
25082508
```
25092509
25102510
#### Parameters
25112511
25122512
| Parameter | Type | Description |
25132513
| --- | --- | --- |
2514-
| type | [Type](./firestore_lite_pipelines.md#type) | The type to check for. |
2514+
| type | string | The type to check for. |
25152515
25162516
<b>Returns:</b>
25172517

docs-devsite/firestore_lite_pipelines.md

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ https://github.com/firebase/firebase-js-sdk
114114
| [first(expression)](./firestore_lite_pipelines.md#first_1138a27) | Creates an aggregation that finds the first value of an expression across multiple stage inputs. |
115115
| [greaterThan(expression, value)](./firestore_lite_pipelines.md#greaterthan_01df3cf) | Creates an expression that checks if an expression is greater than a constant value. |
116116
| [greaterThanOrEqual(expression, value)](./firestore_lite_pipelines.md#greaterthanorequal_01df3cf) | Creates an expression that checks if an expression is greater than or equal to a constant value. |
117-
| [isType(expression, type)](./firestore_lite_pipelines.md#istype_27398ce) | Creates an expression that checks if the result of an expression is of the given type. |
117+
| [isType(expression, type)](./firestore_lite_pipelines.md#istype_e58f382) | Creates an expression that checks if the result of an expression is of the given type. |
118118
| [last(expression)](./firestore_lite_pipelines.md#last_1138a27) | Creates an aggregation that finds the last value of an expression across multiple stage inputs. |
119119
| [length\_2(expression)](./firestore_lite_pipelines.md#length_2_1138a27) | Creates an expression that calculates the length of a string, array, map, vector, or bytes. |
120120
| [lessThan(expression, value)](./firestore_lite_pipelines.md#lessthan_01df3cf) | Creates an expression that checks if an expression is less than a constant value. |
@@ -210,7 +210,7 @@ https://github.com/firebase/firebase-js-sdk
210210
| [greaterThan(fieldName, value)](./firestore_lite_pipelines.md#greaterthan_65e2f32) | Creates an expression that checks if a field's value is greater than a constant value. |
211211
| [greaterThanOrEqual(fieldName, value)](./firestore_lite_pipelines.md#greaterthanorequal_2e16acb) | Creates an expression that checks if a field's value is greater than or equal to an expression. |
212212
| [greaterThanOrEqual(fieldName, value)](./firestore_lite_pipelines.md#greaterthanorequal_65e2f32) | Creates an expression that checks if a field's value is greater than or equal to a constant value. |
213-
| [isType(fieldName, type)](./firestore_lite_pipelines.md#istype_5da287e) | Creates an expression that checks if the value in the specified field is of the given type. |
213+
| [isType(fieldName, type)](./firestore_lite_pipelines.md#istype_ec95173) | Creates an expression that checks if the value in the specified field is of the given type. |
214214
| [last(fieldName)](./firestore_lite_pipelines.md#last_e5b0480) | Creates an aggregation that finds the last value of a field across multiple stage inputs. |
215215
| [length\_2(fieldName)](./firestore_lite_pipelines.md#length_2_e5b0480) | Creates an expression that calculates the length of a string, array, map, vector, or bytes. |
216216
| [lessThan(fieldName, expression)](./firestore_lite_pipelines.md#lessthan_1e91657) | Creates an expression that checks if a field's value is less than an expression. |
@@ -479,7 +479,6 @@ https://github.com/firebase/firebase-js-sdk
479479
| [TimeGranularity](./firestore_lite_pipelines.md#timegranularity) | Specify time granularity for expressions. |
480480
| [TimePart](./firestore_lite_pipelines.md#timepart) | Specify time parts for <code>timestampExtract</code> expressions. |
481481
| [TimeUnit](./firestore_lite_pipelines.md#timeunit) | Specify time units for expressions. |
482-
| [Type](./firestore_lite_pipelines.md#type) | An enumeration of the different types generated by the Firestore backend.<ul> <li>Numerics evaluate directly to backend representation (<code>int64</code> or <code>float64</code>), not JS <code>number</code>.</li> <li>JavaScript <code>Date</code> and firestore <code>Timestamp</code> objects strictly evaluate to <code>'timestamp'</code>.</li> <li>Advanced configurations parsing backend types (such as <code>decimal128</code>, <code>max_key</code> or <code>min_key</code> from BSON) are also incorporated in this union string type. Note that <code>decimal128</code> is a backend-only numeric type that the JavaScript SDK cannot create natively, but can be evaluated in pipelines.</li> </ul> |
483482
| [UnionStageOptions](./firestore_lite_pipelines.md#unionstageoptions) | Options defining how a UnionStage is evaluated. See [Pipeline.union()](./firestore_pipelines.pipeline.md#pipelineunion)<!-- -->. |
484483
| [UnnestStageOptions](./firestore_lite_pipelines.md#unneststageoptions) | Represents the specific options available for configuring an <code>UnnestStage</code> within a pipeline. |
485484
| [WhereStageOptions](./firestore_lite_pipelines.md#wherestageoptions) | Options defining how a WhereStage is evaluated. See [Pipeline.where()](./firestore_pipelines.pipeline.md#pipelinewhere)<!-- -->. |
@@ -3099,24 +3098,24 @@ greaterThanOrEqual(field("quantity"), 10);
30993098

31003099
```
31013100

3102-
### isType(expression, type) {:#istype_27398ce}
3101+
### isType(expression, type) {:#istype_e58f382}
31033102

31043103
Creates an expression that checks if the result of an expression is of the given type.
31053104

3106-
Null or undefined fields evaluate to skip/error. Use `ifAbsent()` / `isAbsent()` to evaluate missing data.
3105+
Null or undefined fields evaluate to skip/error. Use `ifAbsent()` / `isAbsent()` to evaluate missing data. Supported values for `type` are: `'null'`<!-- -->, `'array'`<!-- -->, `'boolean'`<!-- -->, `'bytes'`<!-- -->, `'timestamp'`<!-- -->, `'geo_point'`<!-- -->, `'number'`<!-- -->, `'int32'`<!-- -->, `'int64'`<!-- -->, `'float64'`<!-- -->, `'decimal128'`<!-- -->, `'map'`<!-- -->, `'reference'`<!-- -->, `'string'`<!-- -->, `'vector'`<!-- -->, `'max_key'`<!-- -->, `'min_key'`<!-- -->, `'object_id'`<!-- -->, `'regex'`<!-- -->, `'request_timestamp'`<!-- -->.
31073106

31083107
<b>Signature:</b>
31093108

31103109
```typescript
3111-
export declare function isType(expression: Expression, type: Type): BooleanExpression;
3110+
export declare function isType(expression: Expression, type: string): BooleanExpression;
31123111
```
31133112

31143113
#### Parameters
31153114

31163115
| Parameter | Type | Description |
31173116
| --- | --- | --- |
31183117
| expression | [Expression](./firestore_lite_pipelines.expression.md#expression_class) | The expression to check. |
3119-
| type | [Type](./firestore_lite_pipelines.md#type) | The type to check for. |
3118+
| type | string | The type to check for. |
31203119

31213120
<b>Returns:</b>
31223121

@@ -6075,24 +6074,24 @@ greaterThanOrEqual("score", 80);
60756074

60766075
```
60776076

6078-
### isType(fieldName, type) {:#istype_5da287e}
6077+
### isType(fieldName, type) {:#istype_ec95173}
60796078

60806079
Creates an expression that checks if the value in the specified field is of the given type.
60816080

6082-
Null or undefined fields evaluate to skip/error. Use `ifAbsent()` / `isAbsent()` to evaluate missing data.
6081+
Null or undefined fields evaluate to skip/error. Use `ifAbsent()` / `isAbsent()` to evaluate missing data. Supported values for `type` are: `'null'`<!-- -->, `'array'`<!-- -->, `'boolean'`<!-- -->, `'bytes'`<!-- -->, `'timestamp'`<!-- -->, `'geo_point'`<!-- -->, `'number'`<!-- -->, `'int32'`<!-- -->, `'int64'`<!-- -->, `'float64'`<!-- -->, `'decimal128'`<!-- -->, `'map'`<!-- -->, `'reference'`<!-- -->, `'string'`<!-- -->, `'vector'`<!-- -->, `'max_key'`<!-- -->, `'min_key'`<!-- -->, `'object_id'`<!-- -->, `'regex'`<!-- -->, `'request_timestamp'`<!-- -->.
60836082

60846083
<b>Signature:</b>
60856084

60866085
```typescript
6087-
export declare function isType(fieldName: string, type: Type): BooleanExpression;
6086+
export declare function isType(fieldName: string, type: string): BooleanExpression;
60886087
```
60896088

60906089
#### Parameters
60916090

60926091
| Parameter | Type | Description |
60936092
| --- | --- | --- |
60946093
| fieldName | string | The name of the field to check. |
6095-
| type | [Type](./firestore_lite_pipelines.md#type) | The type to check for. |
6094+
| type | string | The type to check for. |
60966095

60976096
<b>Returns:</b>
60986097

@@ -12070,18 +12069,6 @@ Specify time units for expressions.
1207012069
export declare type TimeUnit = 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day';
1207112070
```
1207212071

12073-
## Type
12074-
12075-
An enumeration of the different types generated by the Firestore backend.
12076-
12077-
<ul> <li>Numerics evaluate directly to backend representation (`int64` or `float64`<!-- -->), not JS `number`<!-- -->.</li> <li>JavaScript `Date` and firestore `Timestamp` objects strictly evaluate to `'timestamp'`<!-- -->.</li> <li>Advanced configurations parsing backend types (such as `decimal128`<!-- -->, `max_key` or `min_key` from BSON) are also incorporated in this union string type. Note that `decimal128` is a backend-only numeric type that the JavaScript SDK cannot create natively, but can be evaluated in pipelines.</li> </ul>
12078-
12079-
<b>Signature:</b>
12080-
12081-
```typescript
12082-
export declare type Type = 'null' | 'array' | 'boolean' | 'bytes' | 'timestamp' | 'geo_point' | 'number' | 'int32' | 'int64' | 'float64' | 'decimal128' | 'map' | 'reference' | 'string' | 'vector' | 'max_key' | 'min_key' | 'object_id' | 'regex' | 'request_timestamp';
12083-
```
12084-
1208512072
## UnionStageOptions
1208612073

1208712074
Options defining how a UnionStage is evaluated. See [Pipeline.union()](./firestore_pipelines.pipeline.md#pipelineunion)<!-- -->.

docs-devsite/firestore_pipelines.expression.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2499,19 +2499,19 @@ field("title").arrayContains(1).isError();
24992499
25002500
Creates an expression that checks if the result of this expression is of the given type.
25012501
2502-
Null or undefined fields evaluate to skip/error. Use `ifAbsent()` / `isAbsent()` to evaluate missing data.
2502+
Null or undefined fields evaluate to skip/error. Use `ifAbsent()` / `isAbsent()` to evaluate missing data. Supported values for `type` are: `'null'`<!-- -->, `'array'`<!-- -->, `'boolean'`<!-- -->, `'bytes'`<!-- -->, `'timestamp'`<!-- -->, `'geo_point'`<!-- -->, `'number'`<!-- -->, `'int32'`<!-- -->, `'int64'`<!-- -->, `'float64'`<!-- -->, `'decimal128'`<!-- -->, `'map'`<!-- -->, `'reference'`<!-- -->, `'string'`<!-- -->, `'vector'`<!-- -->, `'max_key'`<!-- -->, `'min_key'`<!-- -->, `'object_id'`<!-- -->, `'regex'`<!-- -->, `'request_timestamp'`<!-- -->.
25032503
25042504
<b>Signature:</b>
25052505
25062506
```typescript
2507-
isType(type: Type): BooleanExpression;
2507+
isType(type: string): BooleanExpression;
25082508
```
25092509
25102510
#### Parameters
25112511
25122512
| Parameter | Type | Description |
25132513
| --- | --- | --- |
2514-
| type | [Type](./firestore_pipelines.md#type) | The type to check for. |
2514+
| type | string | The type to check for. |
25152515
25162516
<b>Returns:</b>
25172517

0 commit comments

Comments
 (0)