@itwin/sheet-numbering-views-schema 0.0.0-stage → 1.0.0-dev.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/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ # MIT License
2
+
3
+ Copyright © 2017-2026 Bentley Systems, Incorporated. All rights reserved.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,9 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # @itwin/sheet-numbering-views-schema
2
+
3
+ Copyright © Bentley Systems, Incorporated. All rights reserved. See [LICENSE.md](./LICENSE.md) for license terms and full copyright notice.
4
+
5
+ [iTwin.js](http://itwinjs.org) is an open source platform for creating, querying, modifying, and displaying Infrastructure Digital Twins.
6
+
7
+ ## BIS Schemas
8
+
9
+ The acronym “BIS” stands for “Base Infrastructure Schemas”. BIS is an “open” and extensible family of schemas that is modularized into Domains. Please go to [iTwinjs.org](https://www.itwinjs.org/bis/) for more information.
@@ -0,0 +1 @@
1
+ {"$schema":"https://dev.bentley.com/json_schemas/ec/32/ecschema","name":"SheetNumberingViews","version":"01.00.00","alias":"snumViews","description":"Contains classes and relationships for sheet numbering.","references":[{"name":"CoreCustomAttributes","version":"01.00.05"},{"name":"BisCustomAttributes","version":"01.00.00"},{"name":"BisCore","version":"01.00.28"},{"name":"ECDbMap","version":"02.00.04"}],"customAttributes":[{"className":"CoreCustomAttributes.ProductionStatus","SupportedUse":"NotForProduction"},{"className":"BisCustomAttributes.SchemaLayerInfo","Value":"Application"}],"items":{"SheetIndexContainerView":{"schemaItemType":"EntityClass","label":"SheetIndex Container View","description":"View that returns the number of children under a parent. This can be either a SheetIndex or SheetIndexFolder.","modifier":"Abstract","properties":[{"name":"GroupCount","type":"PrimitiveProperty","description":"The total number of sheets within the same parent group as this sheet","typeName":"int"}],"customAttributes":[{"className":"ECDbMap.QueryView","Query":"\n SELECT\n [sr].Parent.id AS ECInstanceId,\n [e].ECClassId AS [ECClassId],\n -- The number of SheetReferences that share a parent, again, cast to an integer\n CAST(COUNT([sr].[ECInstanceId]) OVER (PARTITION BY [sr].[Parent].[Id]) AS INTEGER) AS [GroupCount]\n FROM bis.SheetReference [sr] \n INNER JOIN bis.Element e ON sr.Parent.id = e.ECInstanceId\n "}]},"SheetIndexView":{"schemaItemType":"EntityClass","label":"SheetIndex View","description":"View that returns the total number of sheets in a SheetIndex","modifier":"Abstract","properties":[{"name":"PageCount","type":"PrimitiveProperty","description":"The total number of sheet references across the entire sheet index tree","typeName":"int"}],"customAttributes":[{"className":"ECDbMap.QueryView","Query":"\n SELECT \n ECInstanceId,\n ECClassId,\n PageCount\n FROM (\n WITH\n -- General Notes:\n -- There are a number of times that column names are aliased arbitrarily.\n -- This is to avoid an issue with CTEs not respecting qualifiers. See this issue: https://github.com/iTwin/itwinjs-core/issues/8571\n\n -- Recursively traverses the tree from root to leaves, building hierarchical paths.\n treeTraversal ([ECInstanceId], [ECClassId], [DirectParentId], [RootId]) AS (\n -- Start with root nodes-SheetIndexes\n SELECT\n si.ECInstanceId,\n si.ECClassId,\n NULL AS [DirectParentId],\n si.ECInstanceId AS [RootId]\n FROM bis:SheetIndex si\n\n UNION ALL\n -- Recursively add children to parents, building hierarchical sort paths\n SELECT\n child.ECInstanceId,\n child.ECClassId,\n child.NodeParentId AS [DirectParentId],\n parent.RootId AS [RootId]\n FROM treeTraversal parent\n JOIN (\n -- A table of all possible children joined to their parents\n SELECT\n [sr].[ECInstanceId],\n ECClassId,\n [sr].[Parent].[Id] AS [NodeParentId]\n FROM\n [bis].[SheetReference] [sr]\n\n UNION ALL\n\n SELECT\n [sif].[ECInstanceId],\n ECClassId,\n [sif].[Parent].[Id] AS [NodeParentId]\n FROM\n [bis].[SheetIndexFolder] [sif]\n ) child ON child.NodeParentId = parent.ECInstanceId\n )\n -- Final result: Counts the sheet under eact group of SheetIndex\n SELECT\n RootId AS ECInstanceId,\n ec_classid('bis', 'SheetIndex') AS ECClassId,\n CAST(COUNT(ECInstanceId) AS INTEGER) AS PageCount\n FROM treeTraversal WHERE ECClassId = ec_classid('bis', 'SheetReference') GROUP BY RootId\n )\n "}]},"SheetReferenceView":{"schemaItemType":"EntityClass","label":"SheetReference View","description":"Views the calculated properties of a SheetReference","modifier":"Abstract","properties":[{"name":"SheetNumber","type":"PrimitiveProperty","description":"The formatted sheet identifier of the sheet","typeName":"string"},{"name":"GroupNumber","type":"PrimitiveProperty","description":"The sequential number of this sheet within its parent group, ordered by entry priority","typeName":"int"},{"name":"PageNumber","type":"PrimitiveProperty","description":"The global sequential page number of this sheet across the entire sheet index tree","typeName":"int"}],"customAttributes":[{"className":"ECDbMap.QueryView","Query":"\n SELECT \n ECInstanceId,\n ECClassId,\n SheetNumber,\n GroupNumber,\n PageNumber\n FROM (\n WITH\n -- General Notes:\n -- There are a number of times that column names are aliased arbitrarily.\n -- This is to avoid an issue with CTEs not respecting qualifiers. See this issue: https://github.com/iTwin/itwinjs-core/issues/8571\n\n -- Recursively traverses the tree from root to leaves, building hierarchical paths.\n -- Creates a global ordering based on depth-frist traversal with respect to EntryPriority.\n -- The SortPath ensures proper tree traversal order for sequential number assignment.\n -- AssemblyPath is included only for debugging purposes \n treeTraversal ([ECInstanceId], [ECClassId], [SheetNumber], [Priority], [DirectParentId], [AssemblyPath], [SortPath]) AS (\n -- Start with root nodes-SheetIndexes\n SELECT\n si.ECInstanceId,\n si.ECClassId,\n COALESCE([si].[CodeValue], [si].[UserLabel]) AS [SheetNumber],\n 0 AS [Priority],\n NULL AS [DirectParentId],\n COALESCE([si].[CodeValue], [si].[UserLabel]) AS [AssemblyPath],\n -- Use string padding for consistent sorting - pad to 10 digits with leading zeros\n SUBSTR('0000000000' || CAST(0 AS TEXT), -10) AS [SortPath]\n FROM bis:SheetIndex si\n\n UNION ALL\n -- Recursively add children to parents, building hierarchical sort paths\n SELECT\n child.ECInstanceId,\n child.ECClassId,\n child.SheetNumber,\n child.NodePriority AS [Priority],\n child.NodeParentId AS [DirectParentId],\n parent.AssemblyPath || '->' || child.SheetNumber AS [AssemblyPath],\n parent.SortPath || '.' || SUBSTR('0000000000' || CAST(COALESCE(child.NodePriority, 0) AS TEXT), -10) AS [SortPath]\n FROM treeTraversal parent\n JOIN (\n -- A table of all possible children joined to their parents\n SELECT\n [sr].[ECInstanceId],\n ECClassId,\n COALESCE([sr].[CodeValue], [sr].[UserLabel]) AS [SheetNumber],\n [sr].[EntryPriority] AS [NodePriority],\n [sr].[Parent].[Id] AS [NodeParentId]\n FROM\n [bis].[SheetReference] [sr]\n\n UNION ALL\n\n SELECT\n [sif].[ECInstanceId],\n ECClassId,\n COALESCE([sif].[CodeValue], [sif].[UserLabel]) AS [SheetNumber],\n [sif].[EntryPriority] AS [NodePriority],\n [sif].[Parent].[Id] AS [NodeParentId]\n FROM\n [bis].[SheetIndexFolder] [sif]\n ) child ON child.NodeParentId = parent.ECInstanceId\n )\n -- Final result: Returns only SheetReference node due to inner join\n SELECT\n ECInstanceId,\n ECClassId,\n SheetNumber,\n -- Partitioning by class to filter to SheetReferences\n CAST(ROW_NUMBER() OVER (PARTITION BY ECClassId ORDER BY SortPath) AS INTEGER) AS [PageNumber],\n -- An assigned a Row Number for rows that share a parent and are ordered by their EntryPriority \n -- and cast to an integer because it's a long otherwise for some reason\n CAST(ROW_NUMBER() OVER (PARTITION BY DirectParentId ORDER BY Priority) AS INTEGER) AS [GroupNumber]\n FROM treeTraversal\n WHERE ECClassId = ec_classid('bis', 'SheetReference')\n ORDER BY SortPath\n )\n "}]}}}
@@ -0,0 +1,188 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- ==================================================================================
3
+ | * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ | * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ ======================================================================================= -->
6
+ <ECSchema schemaName="SheetNumberingViews" alias="snumViews" version="01.00.00" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.2" description="Contains classes and relationships for sheet numbering.">
7
+ <ECSchemaReference name="CoreCustomAttributes" version="01.00.03" alias="CoreCA" />
8
+ <ECSchemaReference name="BisCustomAttributes" version="01.00.00" alias="bisCA"/>
9
+ <ECSchemaReference name="BisCore" version="01.00.16" alias="bis"/>
10
+ <ECSchemaReference name="ECDbMap" version="02.00.04" alias="ecdbmap"/>
11
+
12
+ <ECCustomAttributes>
13
+ <ProductionStatus xmlns="CoreCustomAttributes.01.00.03">
14
+ <SupportedUse>NotForProduction</SupportedUse>
15
+ </ProductionStatus>
16
+ <SchemaLayerInfo xmlns="BisCustomAttributes.01.00.00">
17
+ <Value>Application</Value>
18
+ </SchemaLayerInfo>
19
+ </ECCustomAttributes>
20
+
21
+ <ECEntityClass typeName="SheetIndexContainerView" modifier="Abstract" displayLabel="SheetIndex Container View" description="View that returns the number of children under a parent. This can be either a SheetIndex or SheetIndexFolder.">
22
+ <ECCustomAttributes>
23
+ <QueryView xmlns="ECDbMap.02.00.04">
24
+ <Query>
25
+ SELECT
26
+ [sr].Parent.id AS ECInstanceId,
27
+ [e].ECClassId AS [ECClassId],
28
+ -- The number of SheetReferences that share a parent, again, cast to an integer
29
+ CAST(COUNT([sr].[ECInstanceId]) OVER (PARTITION BY [sr].[Parent].[Id]) AS INTEGER) AS [GroupCount]
30
+ FROM bis.SheetReference [sr]
31
+ INNER JOIN bis.Element e ON sr.Parent.id = e.ECInstanceId
32
+ </Query>
33
+ </QueryView>
34
+ </ECCustomAttributes>
35
+ <ECProperty propertyName="GroupCount" typeName="int" description="The total number of sheets within the same parent group as this sheet"/>
36
+ </ECEntityClass>
37
+ <ECEntityClass typeName="SheetIndexView" modifier="Abstract" displayLabel="SheetIndex View" description="View that returns the total number of sheets in a SheetIndex">
38
+ <ECCustomAttributes>
39
+ <QueryView xmlns="ECDbMap.02.00.04">
40
+ <Query>
41
+ SELECT
42
+ ECInstanceId,
43
+ ECClassId,
44
+ PageCount
45
+ FROM (
46
+ WITH
47
+ -- General Notes:
48
+ -- There are a number of times that column names are aliased arbitrarily.
49
+ -- This is to avoid an issue with CTEs not respecting qualifiers. See this issue: https://github.com/iTwin/itwinjs-core/issues/8571
50
+
51
+ -- Recursively traverses the tree from root to leaves, building hierarchical paths.
52
+ treeTraversal ([ECInstanceId], [ECClassId], [DirectParentId], [RootId]) AS (
53
+ -- Start with root nodes-SheetIndexes
54
+ SELECT
55
+ si.ECInstanceId,
56
+ si.ECClassId,
57
+ NULL AS [DirectParentId],
58
+ si.ECInstanceId AS [RootId]
59
+ FROM bis:SheetIndex si
60
+
61
+ UNION ALL
62
+ -- Recursively add children to parents, building hierarchical sort paths
63
+ SELECT
64
+ child.ECInstanceId,
65
+ child.ECClassId,
66
+ child.NodeParentId AS [DirectParentId],
67
+ parent.RootId AS [RootId]
68
+ FROM treeTraversal parent
69
+ JOIN (
70
+ -- A table of all possible children joined to their parents
71
+ SELECT
72
+ [sr].[ECInstanceId],
73
+ ECClassId,
74
+ [sr].[Parent].[Id] AS [NodeParentId]
75
+ FROM
76
+ [bis].[SheetReference] [sr]
77
+
78
+ UNION ALL
79
+
80
+ SELECT
81
+ [sif].[ECInstanceId],
82
+ ECClassId,
83
+ [sif].[Parent].[Id] AS [NodeParentId]
84
+ FROM
85
+ [bis].[SheetIndexFolder] [sif]
86
+ ) child ON child.NodeParentId = parent.ECInstanceId
87
+ )
88
+ -- Final result: Counts the sheet under eact group of SheetIndex
89
+ SELECT
90
+ RootId AS ECInstanceId,
91
+ ec_classid('bis', 'SheetIndex') AS ECClassId,
92
+ CAST(COUNT(ECInstanceId) AS INTEGER) AS PageCount
93
+ FROM treeTraversal WHERE ECClassId = ec_classid('bis', 'SheetReference') GROUP BY RootId
94
+ )
95
+ </Query>
96
+ </QueryView>
97
+ </ECCustomAttributes>
98
+ <ECProperty propertyName="PageCount" typeName="int" description="The total number of sheet references across the entire sheet index tree"/>
99
+ </ECEntityClass>
100
+ <ECEntityClass typeName="SheetReferenceView" modifier="Abstract" displayLabel="SheetReference View" description="Views the calculated properties of a SheetReference">
101
+ <ECCustomAttributes>
102
+ <QueryView xmlns="ECDbMap.02.00.04">
103
+ <Query>
104
+ SELECT
105
+ ECInstanceId,
106
+ ECClassId,
107
+ SheetNumber,
108
+ GroupNumber,
109
+ PageNumber
110
+ FROM (
111
+ WITH
112
+ -- General Notes:
113
+ -- There are a number of times that column names are aliased arbitrarily.
114
+ -- This is to avoid an issue with CTEs not respecting qualifiers. See this issue: https://github.com/iTwin/itwinjs-core/issues/8571
115
+
116
+ -- Recursively traverses the tree from root to leaves, building hierarchical paths.
117
+ -- Creates a global ordering based on depth-frist traversal with respect to EntryPriority.
118
+ -- The SortPath ensures proper tree traversal order for sequential number assignment.
119
+ -- AssemblyPath is included only for debugging purposes
120
+ treeTraversal ([ECInstanceId], [ECClassId], [SheetNumber], [Priority], [DirectParentId], [AssemblyPath], [SortPath]) AS (
121
+ -- Start with root nodes-SheetIndexes
122
+ SELECT
123
+ si.ECInstanceId,
124
+ si.ECClassId,
125
+ COALESCE([si].[CodeValue], [si].[UserLabel]) AS [SheetNumber],
126
+ 0 AS [Priority],
127
+ NULL AS [DirectParentId],
128
+ COALESCE([si].[CodeValue], [si].[UserLabel]) AS [AssemblyPath],
129
+ -- Use string padding for consistent sorting - pad to 10 digits with leading zeros
130
+ SUBSTR('0000000000' || CAST(0 AS TEXT), -10) AS [SortPath]
131
+ FROM bis:SheetIndex si
132
+
133
+ UNION ALL
134
+ -- Recursively add children to parents, building hierarchical sort paths
135
+ SELECT
136
+ child.ECInstanceId,
137
+ child.ECClassId,
138
+ child.SheetNumber,
139
+ child.NodePriority AS [Priority],
140
+ child.NodeParentId AS [DirectParentId],
141
+ parent.AssemblyPath || '->' || child.SheetNumber AS [AssemblyPath],
142
+ parent.SortPath || '.' || SUBSTR('0000000000' || CAST(COALESCE(child.NodePriority, 0) AS TEXT), -10) AS [SortPath]
143
+ FROM treeTraversal parent
144
+ JOIN (
145
+ -- A table of all possible children joined to their parents
146
+ SELECT
147
+ [sr].[ECInstanceId],
148
+ ECClassId,
149
+ COALESCE([sr].[CodeValue], [sr].[UserLabel]) AS [SheetNumber],
150
+ [sr].[EntryPriority] AS [NodePriority],
151
+ [sr].[Parent].[Id] AS [NodeParentId]
152
+ FROM
153
+ [bis].[SheetReference] [sr]
154
+
155
+ UNION ALL
156
+
157
+ SELECT
158
+ [sif].[ECInstanceId],
159
+ ECClassId,
160
+ COALESCE([sif].[CodeValue], [sif].[UserLabel]) AS [SheetNumber],
161
+ [sif].[EntryPriority] AS [NodePriority],
162
+ [sif].[Parent].[Id] AS [NodeParentId]
163
+ FROM
164
+ [bis].[SheetIndexFolder] [sif]
165
+ ) child ON child.NodeParentId = parent.ECInstanceId
166
+ )
167
+ -- Final result: Returns only SheetReference node due to inner join
168
+ SELECT
169
+ ECInstanceId,
170
+ ECClassId,
171
+ SheetNumber,
172
+ -- Partitioning by class to filter to SheetReferences
173
+ CAST(ROW_NUMBER() OVER (PARTITION BY ECClassId ORDER BY SortPath) AS INTEGER) AS [PageNumber],
174
+ -- An assigned a Row Number for rows that share a parent and are ordered by their EntryPriority
175
+ -- and cast to an integer because it's a long otherwise for some reason
176
+ CAST(ROW_NUMBER() OVER (PARTITION BY DirectParentId ORDER BY Priority) AS INTEGER) AS [GroupNumber]
177
+ FROM treeTraversal
178
+ WHERE ECClassId = ec_classid('bis', 'SheetReference')
179
+ ORDER BY SortPath
180
+ )
181
+ </Query>
182
+ </QueryView>
183
+ </ECCustomAttributes>
184
+ <ECProperty propertyName="SheetNumber" typeName="string" description="The formatted sheet identifier of the sheet"/>
185
+ <ECProperty propertyName="GroupNumber" typeName="int" description="The sequential number of this sheet within its parent group, ordered by entry priority"/>
186
+ <ECProperty propertyName="PageNumber" typeName="int" description="The global sequential page number of this sheet across the entire sheet index tree"/>
187
+ </ECEntityClass>
188
+ </ECSchema>
package/package.json CHANGED
@@ -1,6 +1,24 @@
1
- {
2
- "name": "@itwin/sheet-numbering-views-schema",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
1
+ {
2
+ "name": "@itwin/sheet-numbering-views-schema",
3
+ "license": "MIT",
4
+ "version": "1.0.0-dev.1",
5
+ "homepage": "https://www.itwinjs.org/",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/iTwin/bis-schemas"
9
+ },
10
+ "keywords": [
11
+ "Bentley",
12
+ "BIS",
13
+ "iModel"
14
+ ],
15
+ "description": "SheetNumberingViews BIS Domains",
16
+ "author": {
17
+ "name": "Bentley Systems, Inc.",
18
+ "url": "http://www.bentley.com"
19
+ },
20
+ "exports" : {
21
+ "./SheetNumberingViews.ecschema.xml": "./SheetNumberingViews.ecschema.xml",
22
+ "./SheetNumberingViews.ecschema.json": "./SheetNumberingViews.ecschema.json"
23
+ }
24
+ }